I would like to check if selected updates are installed on a certain computer.
This is my attempt so far:
$HotfixInstaled = Get-Hotfix | Select-Object -Property HotFixID | out-string
$HotfixRequared = @("KB4477029", "KB4486458", "KB4480959")
Compare-Object $HotfixRequared $HotfixInstaled -Property HotFixID | where {$_.sideindicator -eq "<="}
The main problem is, that Compare-Object
could't find items that are in $HotfixRequared
and in both variables at the same time.
Two problems here:
Out-String
makes it hard to compare the objects since you destroy the array structure of the returned object and create a string-array with every letter being its own field. Don't do that.-IncludeEqual
Switch of Compare-Object
and change your Where-Object
query in the same manner.This should give you all Hotfixes that are in $HotfixRequarded
and in both:
$HotfixInstaled = Get-Hotfix | Select-Object -Property HotFixID
$HotfixRequared = @("KB4477029", "KB4486458", "KB4480959")
Compare-Object $HotfixRequared ($HotfixInstaled.HotFixID) -IncludeEqual| Where-Object {$_.sideindicator -eq "<=" -or $_.sideindicator -eq "=="}