Gather complete, historical Windows Update history in PowerShell
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.