DCSIMG
QuickTip: Comparing installed HotFixes on a two node Cluster - Shay Levy

Shay Levy

If you repeat it, PowerShell it!

QuickTip: Comparing installed HotFixes on a two node Cluster

We had a Risk and Health Assessment Program (RAP) for SQL Server running in our environment in the last few days and one of the issues in the final report was:

image

 

My PowerShell "wheels" started to roll and I suggested our team have a script to check for such inconsistences. So, here's how we can perform a quick check against a two node cluster (or any other pair of computers) using PowerShell and find if the installed hotfixes are not identical.

First we use the Get-HotFix cmdlet to retrieve the list of hot-fix installed on each cluster node and then we use the Compare-Object cmdlet to compare the collections based on the HotFixID property. No result means the two nodes have the same set of hot-fixes installed and no action needs to be performed.

PS > $node1 = Get-HotFix -ComputerName ClusterNode1
PS > $node2 = Get-HotFix -ComputerName ClusterNode2
PS > Compare-Object -ReferenceObject $node1 -DifferenceObject $node2 -Property HotFixID

HotFixID         SideIndicator
--------           -------------
KB967752       =>

 

The output shows just one hotfix. We can see that the SideIndicator value ('=>') shows that the KB967752 hotfix is installed on ClusterNode2 (DifferenceObject) and that it is missing from ClusterNode1.

Comments

Twitter Trackbacks for QuickTip: Comparing installed HotFixes on a two node Cluster - Shay Levy [microsoft.co.il] on Topsy.com said:

Pingback from  Twitter Trackbacks for                 QuickTip: Comparing installed HotFixes on a two node Cluster - Shay Levy         [microsoft.co.il]        on Topsy.com

# January 12, 2011 7:00 PM

Mike Shepard said:

Very nice.  I think that compare-object is probably one of the more underutilized cmdlets.

# January 12, 2011 7:48 PM

Matthew BETTON said:

Thanks.

Do you know the default value for SyncWindow Parameter of Compare-Object, in PS version 2 ?

In PS V1, it was 5, so we needed to adjust this parameter in order to get correct results...

# January 13, 2011 11:19 PM

ScriptFanatic said:

The default value for the SyncWindow parameter in PowerShell v2 is 2147483647 (i.g [int32]::MaxValue).

# January 14, 2011 10:06 AM

Matthew BETTON said:

Thank you Shay for this article.

I should have seen it in the cmdlet's Help :)

# January 14, 2011 11:17 AM

ScriptFanatic said:

Sometimes default parameter values are not available in help. Check this post:

blogs.microsoft.co.il/.../how-to-get-the-default-parameter-values-of-a-cmdlet.aspx

# January 14, 2011 12:32 PM

Mike Shepard said:

This can also be a useful tool to compare non-clustered servers in a deployment chain...for instance, to make sure your staging servers look just like your production servers.

# January 14, 2011 6:22 PM

Episode 136 – Jim Christopher on StudioShell and a Goodbye to Andy « PowerScripting Podcast said:

Pingback from  Episode 136 – Jim Christopher on StudioShell and a Goodbye to Andy «  PowerScripting Podcast

# January 17, 2011 12:04 AM

Matt Manning said:

This is a great script and will do exactly what I need but I am getting errors when running it:  

PS> $node1 = Get-HotFix -svrnamexxxx ClusterNode1

Get-HotFix : A parameter cannot be found that matches parameter name 'svrnamexxxx'.

At line:1 char:31

+ $node1 = Get-HotFix -svrnamexxxx <<<<  ClusterNode1

   + CategoryInfo          : InvalidArgument: (:) [Get-HotFix], ParameterBindingException

   + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.GetHotFixCommand

# October 17, 2011 5:27 PM

ScriptFanatic said:

@Matt

You need to pass the computer name to the -ComputerName parameter. (there's no -svrnamexxxx parameter).

$node1 = Get-HotFix -ComputerName ClusterNode1

# October 17, 2011 5:46 PM
Leave a Comment

(required) 

(required) 

(optional)

(required) 


Enter the numbers above: