Frage

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"
        }
    }
}
War es hilfreich?

Lösung

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
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top