Lerch Web Wiki

Random, erratic, no responsibility is taken for the correctness of this information

User Tools

Site Tools


Hot(fix) or not(fix)?

Today one of my customers asked me how they can easily compare installed hofixes on Windows Servers.

Powershell to the rescue! To get the installed hotfixes from a server (local or remote) we can use the Get-HotFix cmdlet in Powershell. So all we need to do is compare the output. Depending on the number of hotfixes this can be a pain in the neck if you try to do it manually. And the more servers you need to compare the more pain…

With Powershell hashtables and a little scripting the comparison is easily automated, so you can see which hotfixes are installed on your servers and if they are all on the same hotfix level.

Save the following script as Compare-HotFix.ps1 and give it a try:

    [Parameter(Position=0, Mandatory=$true, ValueFromPipeline=$true)]
Begin {$htHF = @{}}
Process {
    $ServerList | foreach-object {
        Write-Verbose "Getting hotfixes from server $_"
        $hf1 = Get-HotFix -ComputerName $_ | Select-Object -Property HotFixID,CSName
        foreach ($hf in $hf1){
            try {
                if($htHF.Item($hf.HotFixID) -notcontains $hf.CSName){
                $htHF.Item($hf.HotFixID) += $hf.CSName
End {$htHF | Sort-Object -Property Name}

The script takes one or more server names as strings or you can pipe the server names to it.

Use it like this:

.\compare-hotfix.ps1 server1,server2,server3

or this:

$Servers = “server1″,”server2″,”server3″,”serverN”
$Server | .\compare-hotfix.ps1

or if you have a list of server names in a text file you do something like this:

get-content Serverlist.txt | .\compare-hotfix.ps1

Have fun playing around with it!

This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies
powershell/plattform/compare-hotfix.txt · Last modified: 2020/03/24 09:01 (external edit)