This is a copy of my post to Windows 8.1 IT Pro forum. The moderator there said post it here:
I am using powershell to manually apply certain updates and I think I've encountered a bug, but I'm not sure if it's in Powershell or the COM object. It is reproducible in Windows 7 and Windows 8.1.
In order to retrieve a list of known optional updates I am using powershell to init COM IUpdateSearcher:
$Searcher = New-Object -ComObject Microsoft.Update.Searcher $Searcher.Online = $false
... and then search for those updates using its criterion BrowseOnly=1:
$Searcher.Search("IsInstalled=0 and IsHidden=0 and BrowseOnly=1 and AutoSelectOnWebSites=0").Updates
That command returns no results, despite many optional updates being available on the computers I tested. Yet if I remove BrowseOnly=1 the updates with BrowseOnly are returned in the results:
$Searcher.Search("IsInstalled=0 and IsHidden=0 and AutoSelectOnWebSites=0").Updates
I can apply a post search filter to get the results with only BrowseOnly:
$Searcher.Search("IsInstalled=0 and IsHidden=0 and AutoSelectOnWebSites=0").Updates | foreach { if($_.BrowseOnly) { $_ } }
This seems like a bug to me. Would anyone mind trying to reproduce this issue? To reproduce you will need Windows Update to be aware of at least one optional update that is not installed.