Difference between WUA IUpdateSearcher and wmic qfe
Andrew Henderson
I am trying to figure out what are the differences between WUA (Windows Update Agent API) IupdateSearcher and wmic qfe list.
I get different results when I use:
(New-Object -ComObject Microsoft.Update.Session).CreateUpdateSearcher().Search('IsInstalled=1').Updates | Format-Table -AutoSizeAnd when using wmic qfe list:
wmic qfe list briefThe latter includes updates that the former doesn't and vice versa. Why is that?
For example, KB5007273 appears on wmic but doesn't appear on WUA and vice versa, for example, KB4023057 appears on WUA but doesn't appear on wmic
1 Answer
Microsoft lists the differences here:
- WMI
...they can be reliably used only to retrieve updates for Windows OS itself and its components (such as Windows Internet Explorer (IE) or Windows Server roles and features). This will not list updates for any non-inbox software (such as Microsoft Office or Exchange Server).
- WUA
...will list all kind of updates (both Windows and app) but only those installed using Windows Update. [...] excludes any updates installed manually or using custom management scripts.
That said, it looks like you might not be looking at the right place to find updates with WUA. As an example:
# the updatesearcher() method excludes superseded updates:
$UpdateSearcher = (New-Object -ComObject Microsoft.Update.Session).CreateUpdateSearcher().Search('IsInstalled=1').Updates
$UpdateSearcher | Select Title
# returns 7 updates on my machine
# Instead, try searching your WUA history instead.
$WuaHistory = (New-Object -ComObject 'Microsoft.Update.Session').QueryHistory("",0,100) ## first 100 results
# only return successful(2) installations(1)
$WuaHistory | Where {$_.ResultCode -eq 2 -and $_.Operation -eq 1} | Select Title
# Returns 80 updatesIn Windows 10, version 1709, the ability to search for superseded updates was removed.
1