PowerShell

How to check Windows Update History using PowerShell

How to check Windows Update History using PowerShell

Windows systems are routinely updated with the latest patches to improve the performance of a system. Microsoft releases the service and patches as part of the free update service to enhance the Windows computing experience. These updates are automatically installed based on the system settings and rarely needs input from the end users. The free updates are a part of Windows maintenance and support that releases software to fix errors effectively. In order to ensure the secure computing, the Windows Update assures that the system is up to date with the latest security patches, hotfixes, and bug fixes.

The users can check on the update history using PowerShell, Command line or one can also check the update history via Windows settings User interface. In this article, we discuss on how to list all the history of Windows Update events using one of the task automation and configuration management tool such as PowerShell. One can also obtain information about all the current hotfixes or quick fix engineering updates that are downloaded as part of the software patches.

Check Windows Update History using PowerShell

Go to the Start menu and search for Windows PowerShell. Right click on it and click on Run as administrator.

In the command line write the following command that lists the Hotfixes that are installed along with their ID, information on Installed on, description, etc.

wmic qfe list

You can also type the following command to list the hotfixes and its associated description.

get-wmiobject -class win32_quickfixengineering

Additionally, one can also write a query to the computer for Update history and return a pointer to a list of matching records on the Windows system. The queries are written to list the WUA history in a PowerShell by defining some few functions to convert WUA history events of result code to a Name and get the last and latest 50 WUA history. You can modify the objects to list any number of past History of updated events.

# Convert Wua History ResultCode to a Name # 0, and 5 are not used for history # See https://msdn.microsoft.com/en-us/library/windows/desktop/aa387095(v=vs.85).aspx function Convert-WuaResultCodeToName  param( [Parameter(Mandatory=$true)] [int] $ResultCode ) $Result = $ResultCode switch($ResultCode)  2  $Result = "Succeeded"  3  $Result = "Succeeded With Errors"  4  $Result = "Failed"   return $Result  function Get-WuaHistory  # Get a WUA Session $session = (New-Object -ComObject 'Microsoft.Update.Session') # Query the latest 1000 History starting with the first recordp $history = $session.QueryHistory("",0,50) | ForEach-Object  $Result = Convert-WuaResultCodeToName -ResultCode $_.ResultCode # Make the properties hidden in com properties visible. $_ | Add-Member -MemberType NoteProperty -Value $Result -Name Result $Product = $_.Categories | Where-Object $_.Type -eq 'Product' | Select-Object -First 1 -ExpandProperty Name $_ | Add-Member -MemberType NoteProperty -Value $_.UpdateIdentity.UpdateId -Name UpdateId $_ | Add-Member -MemberType NoteProperty -Value $_.UpdateIdentity.RevisionNumber -Name RevisionNumber $_ | Add-Member -MemberType NoteProperty -Value $Product -Name Product -PassThru Write-Output $_  #Remove null records and only return the fields we want $history | Where-Object ![String]::IsNullOrWhiteSpace($_.title) | Select-Object Result, Date, Title, SupportUrl, Product, UpdateId, RevisionNumber 

Then now type the following command to get the updates history events with result date, update title, support URL, and update ID.

# Get all the update History, formatted as a table Get-WuaHistory | Format-Table

That's all.

Sourced from stackoverflow.com.

AppyMouse On-screen Trackpad and Mouse Pointer for Windows Tablets
Tablet users often miss the mouse pointer, especially when they are habitual to using the laptops. The touchscreen Smartphones and tablets come with m...
Middle mouse button not working in Windows 10
The middle mouse button helps you scroll through long webpages and screens with a lot of data. If that stops, well you will end up using the keyboard ...
How to change Left & Right mouse buttons on Windows 10 PC
It's quite a norm that all computer mouse devices are ergonomically designed for right-handed users. But there are mouse devices available which are s...