PowerShell Cmdlet Deep Dive: Get-HotFix
Welcome back to Wahmans Powershell Blog! Today we’re taking a closer look at a super-helpful cmdlet that helps Windows admins quickly check what updates and patches have been applied to one or more systems: Get-HotFix.
What does it do?
Get-Hotfix retrieves the hotfixes (also known as updates or patches) that are installed on the local computer or remote computers. This is a great tool to include in system management, auditing, or troubleshooting scripts.
Example 1: Basic usage
Get all the hotfixes installed on your local machine:
Get-HotFix
This will return a list of all installed updates including the HotFixID, Description, InstalledBy, and InstalledOn fields. This is the easiest way to get a quick view of the updates applied to your system.
Example 2: Filter by HotFix ID
Perhaps you’re looking for a specific update to see whether it’s applied. Say you’re checking if the infamous KB5005565 is installed:
Get-HotFix | Where-Object {$_.HotFixID -eq 'KB5005565'}
This filters the list to only show the specific update if it exists.
Example 3: Check hotfixes on a remote computer
Want to verify installed updates on another system on your network?
Get-HotFix -ComputerName "SERVER01"
This will remotely query the machine named SERVER01 for its installed hotfixes. You may need appropriate permissions and network connectivity to retrieve this data.
Example 4: Export installed hotfixes across multiple computers
In larger environments, you might want to automate the gathering of hotfix information from multiple computers. Here’s a more advanced use case:
$computers = @("SERVER01", "SERVER02", "SERVER03")
foreach ($comp in $computers) {
Get-HotFix -ComputerName $comp |
Select-Object @{Name='ComputerName';Expression={$comp}}, HotFixID, InstalledOn |
Export-Csv -Path "C:\Reports\Hotfix_$comp.csv" -NoTypeInformation
}
This script loops over a list of computer names and exports each system’s hotfix list into a dedicated CSV file. Perfect for auditing or update compliance reports!
Wrapping up
Get-HotFix is a simple yet powerful command when managing updates across local or remote Windows systems. Whether you’re a beginner sysadmin or a PowerShell veteran, it has a place in your toolbox.
Happy scripting, and I will see you in the next post!
Leave a Reply