Gather complete, historical Windows Update history in PowerShell

I am trying to get a list of all updates that a system has ever installed according to the Settings app using PowerShell, with the end goal being a 1:1 comparison between the two.
Lazy tech blogs will give you one of the following, which polls the Win32_QuickFixEngineering WMI location:

get-hotfix
wmic qfe list full
get-wmiobject win32_quickfixengineering

But this doesn't account for everything. According to Microsoft:

Starting with Windows Vista, this class returns only the updates supplied by Microsoft Windows Installer (MSI), Windows Update, Microsoft Update, or Windows Server Update Services. It does not include updates that are supplied by Component Based Servicing (CBS), or other non-hotfix programs or apps.

To supplement this, you'll often see code blocks interfacing with the "Windows.Update.Session" COM Object in PowerShell doing something like this to achieve a (different) list of installed updates:

$Session = New-Object -ComObject Microsoft.Update.Session
$Searcher = $Session.CreateUpdateSearcher()
$historyCount = $Searcher.GetTotalHistoryCount()

But even this doesn't grab an entire, historical list -- I would imagine because the list being pulled from is de-duplicating updates that were installed as Cumulatives and omitting updates that were installed for earlier versions of Windows.
The Settings app, however, lists things installed back over a year ago on my device:

List of updates installed in 2020

Is there a way, using PowerShell, to access this list? Where is Settings getting it from?

5

1 Answer

Use the PSWindowsUpdate module. The Get-WUHistory cmdlet uses the same windows update api (wua) that you tried in your question, but does some additional magic in the background to make things readable:

$history = Get-WUHistory -Last 1000
# Larger than in Settings app, since it includes failed updates
$history.Count
62
$history | sort date -desc | Format-Table Date,KB,@{l='Category';e={[string]$_.Categories[0].Name}},Title
Date KB Category Title
---- -- -------- -----
7/16/2021 4:19:43 PM KB5004237 Windows 10, version 1903 and later 2021-07 Cumulativ...
7/16/2021 4:00:44 PM KB5003537 Windows 10, version 1903 and later 2021-07 Cumulativ...
7/15/2021 5:06:18 PM KB890830 Windows 10 Windows Malicious...
7/7/2021 4:22:58 PM KB5004945 Windows 10, version 1903 and later 2021-07 Cumulativ...

This is the best option I think, though I noticed it doesn't seem to be able to pick up the KB number for new update types like the "Feature Update via Enablement Package", and currently a bug with this module requires a -Last (days) flag or it will loop forever.

I can't confirm what the history limit is, but mine does go back slightly farther than one year.

5

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like