2014-01-08 94 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++ 
} 
相关问题