Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

share|improve this question

2 Answers 2

up vote 11 down vote accepted

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
share|improve this answer
1  
Never knew about get-hotfix. Great nugget of information there. –  Mike Nov 13 '12 at 17:27
    
Be careful when using Get-Hotfix, it only reports a subset of patches. See this Hey Scripting Guy article for more information. @Mike –  Ashley Steel Mar 3 '14 at 18:12
clear-host
$machine1=Read-Host "Enter Machine Name 1:-"
$machine2=Read-Host "Enter Machine Name 2:-"
$machinesone=@(Get-wmiobject -computername  $machine1 -Credential Domain\Adminaccount -query 'select hotfixid from Win32_quickfixengineering')
$machinestwo=@(Get-WmiObject -computername $machine2  -Credential Domain\Adminaccount -query 'select hotfixid from Win32_quickfixengineering')
Compare-Object -RefernceObject $machinesone -DiffernceObject $machinestwo -Property hotfixid
share|improve this answer
1  
Can you explain how querying WMI could be better than running native powershell against each host? –  blaughw Apr 29 at 0:02

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.