PowerShell: Quick way to tell if a particular hotfix is installed – local and remote

A colleague just asked me if there was a quick and easy way to find out if a hotfix was installed on a Windows machine. The answer is “yes, use PowerShell”.

Get-HotFix

will list all the hotfixes installed on the computer. You can then filter this by using Where-Object to Match part of the hotfix ID:

Get-HotFix | Where-Object -Property HotfixID -Match "2823180"

or use EQ to find only fully matching hotfix IDs:

Get-HotFix | Where-Object -Property HotfixID -EQ "KB2823180"

or if you want to shorten the command line:

Get-HotFix | where HotfixID -match "2823180"

You can obviously do this query remotely too, using Enter-PSSession:

Enter-PSSession -Computername rcmhv01 -Credential rcmtech-admin
Get-HotFix | Where-Object -Property HotfixID -EQ "KB2823180"
Exit-PSSession

Note that the Credential will assume the current Active Directory domain, but you can prefix the username with alternativedomain\ if you want to use a different one. The credential prompt will pop up an authentication dialogue to ask for the password. If you’re logged on with an account that has sufficient permissions (e.g. administrator) on the remote machine then you can omit the Credential parameter completely. The PowerShell prompt will change after the Enter-PSSession command to indicate that you’re now executing commands on a different machine.

Or do it on one line:

Invoke-Command -ComputerName rcmhv01 -Credential rcmtech-admin -ScriptBlock {Get-HotFix | Where-Object -Property HotfixID -EQ "KB2823180"}

If you’re having issues running commands remotely then check the steps here.

This entry was posted in PowerShell, Windows and tagged , , , , , , , , , , , , . Bookmark the permalink.

One Response to PowerShell: Quick way to tell if a particular hotfix is installed – local and remote

  1. Pingback: PowerShell: быстрый поиск № KB обвновления windows (локально и удалённо) — Очередной ИТ блокнот

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s