How can I compare installed hotfixes between two Windows servers using PowerShell?

Solution 1:

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