- $out=[collections.arraylist]@()
- gc a.txt|?{$_ -ne ""}|%{
- if ($_ -match "^企业.*(?<!>)$"){
- $name=$_
- }elseif(test-path variable:name){
- if ($_ -match "^执行.*s$"){
- [void]$out.add($name+"`r`n"+$_)
- remove-variable name
- }
- }
- }
- sc out.txt -value $out
复制代码 我来试试powershell |