Windows – How to compare installed hotfixes between two Windows servers using PowerShell

powershellwindows

I need to compare the installed patches between a dev and production environment using PowerShell. How can I do this?

Best Answer

I recently blogged about this problem and came up with this script. You can either run it as a user that is administrator on both machines, or use the -Credential option on the get-hotfix commands.

$server1 = Read-Host "Server 1"
$server2 = Read-Host "Server 2"

$server1Patches = get-hotfix -computer $server1 | Where-Object {$_.HotFixID -ne "File 1"}

$server2Patches = get-hotfix -computer $server2 | Where-Object {$_.HotFixID -ne "File 1"}

Compare-Object ($server1Patches) ($server2Patches) -Property HotFixID