You could try something like this:
# 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
)
# https://learn.microsoft.com/en-us/windows/win32/api/wuapi/ne-wuapi-operationresultcode
$Result = $ResultCode
switch ($ResultCode) {
0 { $Result = "NotStarted; break"}
1 { $Result = "InProgress"; break }
2 { $Result = "Succeeded"; break }
3 { $Result = "Succeeded With Errors"; break }
4 { $Result = "Failed"; break }
5 { $Result = "Aborted"; break }
}
$Result
}
function Get-WuaHistory {
# Get a WUA Session
$session = New-Object -ComObject 'Microsoft.Update.Session'
$searcher = $session.CreateUpdateSearcher()
$historyCount = $searcher.GetTotalHistoryCount()
# Query the latest 1000 History starting with the first record
$session.QueryHistory("", 0, $historyCount) | # criteria, start index, count
ForEach-Object {
[PSCustomObject]@{
Result = (Convert-WuaResultCodeToName -ResultCode $_.ResultCode)
Date = $_.Date
Title = $_.Title
SupportUrl = $_.SupportUrl
Product = ($_.Categories | Where-Object { $_.Type -eq 'Product' } | Select-Object -First 1 -ExpandProperty Name)
UpdateId = ($_.UpdateIdentity.UpdateId)
RevisionNumber = ($_.UpdateIdentity.RevisionNumber)
Description = $_.Description
}
} | Where-Object { ![String]::IsNullOrWhiteSpace($_.title) } #remove null(?) records, return selected properties
}
Get-WuaHistory | export-csv c:\junk\updates.csv -notypeinfo #Format-Table -AutoSize