如何从powershell中的多行输出中读取或处理每一行?

时间:2018-01-22 18:09:02

标签: powershell

Start-Job  -Name test123 -ScriptBlock { dir  'C:\Users\musuresh\Downloads' } 
$output = Get-Job -Name test123 | Receive-Job | Out-String
$output | ForEach { "===$_===" }

输出:

===

    Directory: C:\Users\musuresh\Downloads


Mode                LastWriteTime     Length Name                                                                           
----                -------------     ------ ----                                                                           
d----          1/9/2018   9:19 AM            en                                                                             
-a---         1/15/2018   2:18 PM     104681 3600nvram.pdf                                                                  
-a---         1/15/2018   3:24 PM    5763888 dlm.exe                                                                        
-a---          1/9/2018   9:19 AM     509280 help_en.exe                                                                    
-a---         1/15/2018   3:43 PM   15049960 HP_CLJ3600_64bit_HB.exe                                                        
-a---          1/9/2018  10:47 AM  177776440 LJ-Ent-700-color-MFP-M775-Full-Solution-15315.exe                              
-a---          1/9/2018  10:15 AM   18600800 upd-pcl6-x64-6.5.0.22695.exe                                                   
-a---          1/9/2018  10:58 AM   48774144 zsu-1191239.exe                                                                


===

为什么我不能逐个阅读/处理每一行,比如跳过空行?

0 个答案:

没有答案