質問

I am trying to check a list of computer and see if what patches they are missing, this is been giving me trouble for some reason. I'm sure im overlooking something simple but help would be greatly appreciated please and thank you.

$Computers = "TrinityTechCorp"
$HotFixes = Get-Content HotFixes.csv

ForEach ($Computer in $Computers) {
    $Comparison = get-hotfix -ComputerName $Computer | Select HotFixID
    ForEach ($HotFix in $HotFixes) {
        IF ($Comparison -NotLike "*$HotFix*") {
            Write-Host "$Computer missing $HotFix"
        }
    }
}
役に立ちましたか?

解決

From

$Comparison = get-hotfix -ComputerName $Computer | Select HotFixID

$Comparison will be collection of objects with HotFixId properties.

If you want them as a collection of strings, you have to do:

$Comparison = get-hotfix -ComputerName $Computer | Select -expand HotFixID
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top