Powershell - 我该怎么做

时间:2014-01-08 17:46:36

标签: powershell

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

我想计算并将计数放在(输出中的get-hotfix)

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

1 个答案:

答案 0 :(得分: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++
}