Get-HotFix | Taking on PowerShell one cmdlet at a time | Weekly Blog

Share this post:

This is a part of an on-going blog series written by Adam Gordon. Each week, Adam will walk you through a PowerShell command, showing you when and how to use each one. This week, Adam covers Get-HotFix.

When to use Get-HotFix

The Get-Hotfix cmdlet gets hotfixes, or updates, that are installed on the local computer or specified remote computers.

The updates can be installed by Windows Update, Microsoft Update, Windows Server Update Services, or manually installed.

How to use Get-HotFix

Get all hotfixes on the local computer:




Get hotfixes from multiple computers filtered by a string:

Get-HotFix -Description Security* -ComputerName ITPRO01, ITPRO02 -Credential Domain01\admin01

Get-Hotfix filters the output with the –Description parameter and the string Security that includes the asterisk (*) wildcard.

The –ComputerName parameter includes a comma-separated string of remote computer names.

The –Credential parameter specifies a user account that has permission to access the remote computers and run commands.


Verify if an update is installed and write computer names to a file:

$A = Get-Content -Path ./Servers.txt

$A | ForEach-Object { if (!(Get-HotFix -Id KB957095 -ComputerName $_))

         { Add-Content $_ -Path ./Missing-KB957095.txt }}

The $A variable contains computer names that were obtained by Get-Content from a text file.

The objects in $A are sent down the pipeline to ForEach-Object. An if statement uses the Get-Hotfix cmdlet with the –Id parameter and a specific Id number for each computer name.

If a computer does not have the specified hotfix Id installed, the Add-Content cmdlet writes the computer name to a file.


Get the most recent hotfix on the local computer:

(Get-HotFix | Sort-Object -Property InstalledOn)[-1]

Get-Hotfix sends the objects down the pipeline to the Sort-Object cmdlet.

Sort-Object sorts objects by ascending order and uses the –Property parameter to evaluate each InstalledOn date.

The array notation [-1] selects the most recent installed hotfix.


Need PowerShell training? Check out ITProTV’s PowerShell online IT training courses.