In this tutorial, I will explain how to get Windows update history using PowerShell. This tutorial will be helpful if you want to keep track of updates across multiple machines. By this end, you will know how to retrieve update history, understand what updates have been applied, and troubleshoot any issues that might arise with Windows updates.
Why Track Windows Update History?
Keeping track of Windows updates is crucial for several reasons:
- Security: Ensuring all security patches are applied.
- Compliance: Meeting organizational compliance requirements.
- Troubleshooting: Diagnosing issues caused by recent updates.
- Inventory Management: Keeping an up-to-date record of the software environment.
Note: You need administrative privileges in the system where you want to check.
Get Windows Update History Using PowerShell
First, open PowerShell with administrative privileges. You can do this by searching for “PowerShell” in the Start menu, right-clicking on “Windows PowerShell,” and selecting “Run as administrator.”
Now, let me show you a few methods to get Windows update history using PowerShell.
Using the PSWindowsUpdate Module
The PSWindowsUpdate module is a third-party module that simplifies the management of Windows updates through PowerShell. To use this module, you first need to install it.
Installing PSWindowsUpdate
Install-Module -Name PSWindowsUpdate -Force -SkipPublisherCheckAfter installing the module, you need to import it:
Import-Module PSWindowsUpdateChecking Update History
With the PSWindowsUpdate module installed, you can now check the update history using the Get-WUHistory cmdlet. This cmdlet retrieves a list of updates that have been installed on the system.
Get-WUHistoryThis command will display a list of installed updates, including the date of installation, the title of the update, and the result of the installation.
Filtering Results
To make the output more manageable, you can filter the results. For example, if you want to see only the updates installed in the last 30 days, you can use the following command:
Get-WUHistory | Where-Object { $_.Date -gt (Get-Date).AddDays(-30) }Exporting Update History
You might want to export the update history to a CSV file for reporting purposes. You can do this using the Export-Csv cmdlet:
Get-WUHistory | Export-Csv -Path "C:\Users\Public\Documents\UpdateHistory.csv" -NoTypeInformationCheck out Restart a Windows Service Using PowerShell
Using Built-in PowerShell Cmdlets Get-HotFix
If you prefer not to use third-party modules, you can also retrieve update history using built-in PowerShell cmdlets.
The Get-HotFix cmdlet retrieves information about the hotfixes (updates) that are installed on the local or remote computer.
Get-HotFixThis command provides a list of installed updates, including the description, hotfix ID, and installation date.
Here is the exact output you can see in the screenshot below:

Example: Filtering by Description
If you want to filter the updates by their description, you can use the Where-Object cmdlet. For example, to find all security updates, you can use:
Get-HotFix | Where-Object { $_.Description -like "*Security*" }Exporting HotFix Information
Similar to the PSWindowsUpdate module, you can export the hotfix information to a CSV file:
Get-HotFix | Export-Csv -Path "C:\Users\Public\Documents\HotFixHistory.csv" -NoTypeInformationCheck out Install Git on Windows Using PowerShell
Using the Windows Update API
For more advanced users, the Windows Update API provides a way to programmatically access update information. You can use PowerShell to interact with this API.
$UpdateSession = New-Object -ComObject Microsoft.Update.Session
$UpdateSearcher = $UpdateSession.CreateUpdateSearcher()
$HistoryCount = $UpdateSearcher.GetTotalHistoryCount()
$UpdateHistory = $UpdateSearcher.QueryHistory(0, $HistoryCount)
foreach ($Update in $UpdateHistory) {
Write-Output "Title: $($Update.Title)"
Write-Output "Date: $($Update.Date)"
Write-Output "Result: $($Update.ResultCode)"
}This script creates an update session, queries the update history, and outputs the title, date, and result of each update.
Troubleshooting Update Issues
Sometimes, updates can fail or cause issues. PowerShell can help you troubleshoot these problems.
Checking for Failed Updates
To check for failed updates, you can filter the update history by the result code:
Get-WUHistory | Where-Object { $_.ResultCode -ne 0 }Removing a Specific Update
If you need to uninstall a problematic update, you can use the wusa.exe command in PowerShell:
wusa.exe /uninstall /kb:1234567 /quiet /norestartReplace 1234567 with the KB number of the update you want to remove.
Conclusion
In this tutorial, I explained various methods to get Windows update history using PowerShell. You can use the PSWindowsUpdate module, built-in cmdlets like Get-HotFix, or the Windows Update API, etc.
You may also like:
- Monitor and Manage CPU Usage using Windows PowerShell
- Disable Windows Defender Using PowerShell
- Install Snipping Tool in Windows 11 Using PowerShell
Bijay Kumar is an esteemed author and the mind behind PowerShellFAQs.com, where he shares his extensive knowledge and expertise in PowerShell, with a particular focus on SharePoint projects. Recognized for his contributions to the tech community, Bijay has been honored with the prestigious Microsoft MVP award. With over 15 years of experience in the software industry, he has a rich professional background, having worked with industry giants such as HP and TCS. His insights and guidance have made him a respected figure in the world of software development and administration. Read more.