Earlier this month I posted about a function that I wrote: Get-InstalledUpdates – List all installed updates and hotfixes
In that post, I wrote a little extra code in order to compare the results between multiple devices.
That got me thinking. I also wanted a Compare-InstalledUpdates function.
So, here we go:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
function Compare-InstalledUpdates { param ( [parameter(mandatory=$true)][array]$ComputerName ) $AllUpdates = Get-InstalledUpdates -All -ComputerName $ComputerName | Select-Object KB,Type,@{Name="ComputerName";Expression={$_.PSComputerName}} $AllUpdateNames = $AllUpdates | select -ExpandProperty kb -Unique foreach ($Computer in $ComputerName) { $ComputerUpdates = $AllUpdates | Where-Object {$_.ComputerName -eq "$Computer"} | select -ExpandProperty KB -Unique $Results = Compare-Object $AllUpdateNames $ComputerUpdates | select -ExpandProperty InputObject -Unique $Results | foreach { $Object = New-Object -TypeName PSObject $Object | Add-Member -MemberType NoteProperty -Name 'ComputerName' -Value $Computer $Object | Add-Member -MemberType NoteProperty -Name 'Name' -Value $_ $Object } } } |
This function utilizes my Get-InstalledUpdate function and compares the updates and/or hotfixes between them.