2014-01-08 38 views
0
Get-content -path z:\path\name.txt | 
foreach { 
     (get-hotfix -Computername $_ | 
      Sort-object IUnstalledon)[-1] 
} 

我想計數並把計數在前面(得到修復程序輸出)PowerShell的 - 我怎麼做到這一點

1 computer-name update ncncncncn cncncncncncn date time 
2 computer name..... 

回答

2

也許這樣的事情?

#Count variable 
$i = 0 
Get-content -path z:\path\name.txt | 
foreach { 
     $hotfix = (get-hotfix -Computername $_ | Sort-object IUnstalledon)[-1] 

     #Create your output string "Count ComputerName Hotfix" 
     Write-Output "$i $_ $hotfix" 
     $i++ 
} 
相關問題