Install-WindowsUpdate Misses Updates
On a fresh Windows 2012 R2 Server, I have configured it to use a WSUS server. I manually checked the number of updates to install, there was 40 (IIRC), I then ran boxstarter with my simple package Install-WindowsUpdate -acceptEula and it installed 37 updates and said a reboot was necessary, so I rebooted manually. It now says no updates are needed. But when I manually check there's 7 updates needed. I want boxstarter to install everything.
If I run PSWindowsUpdate module's Get-WUList it lists the 7 updates I see in the OS Windows Update GUI. Get-WUList Criteria, seen via -ShowSearchCriteria, is "IsInstalled=0".
If I do: Get-WUList -Criteria "IsHidden=0 and IsInstalled=0 and Type='Software' and BrowseOnly=0" I get 0 updates. If I change the query to have BrowseOnly=1 I still get 0 results. If I remove the BrowseOnly part I get 7 updates. I tried BrowseOnly!=0, BrowseOnly>0 etc., if BrowseOnly is in the criteria I get 0 updates, if it's not there I get 7 updates. I don't get why this happens.
Looking at the updates that are installed versus not installed I can't work out why some are installed and some are not. Example of not-installed update is KB3013816 (it's BrowseOnly is True, so this update was not installed despite not being optional) and installed KB3162343 (it's BrowseOnly is False, so this update was installed despite being optional).
I've updated my package to be Install-WindowsUpdate -acceptEula -Criteria "IsHidden=0 and IsInstalled=0 and Type='Software'", e.g. I've removed the BrowseOnly criterion that the default has. This installed updates and rebooted the machine automatically. After the reboot boxstarter automatically started but it got an error because my package is not installed (I named it x.ps1, not sure if that's to blame). Checking Get-WUList, 0 updates needed, and manually in GUI no updates available, so all 7 got installed successfully (I can see in them installed in the update history).
Why would BrowseOnly=0 criteria cause updates with BrowseOnly = False to not be selected? I think it should be matching them 0 is False.
Additionally I don't grok why I need to use a package, why I can't just call Install-WindowsUpdates directly from a PowerShell shell. I suppose it's so it can load the package/script after a reboot. It would be nice IMO if you could run it from the shell and it would save the arguments to a temporary script/package.
Update: Checking https://msdn.microsoft.com/en-us/library/windows/desktop/aa386526%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396 I see that != isn't an allowed operator on BrowseOnly, but still only 0 and 1 are the valid values according to that article, so =0 and =1 should have covered all bases. Maybe some updates don't have that field, and when I inspect I'm getting a default value... I'd don't want to guess though, I want to know what's really happening.
Regarding BrowseOnly I'm afraid your guess is probably as good as mine. I too have struggled with this query criteria. The docs are not at all clear.
Regarding why you cant run this from the console instead of a package. I agree that would be ideal and issue #11 covers this use case.
Ah, fair enough, thanks for the response. I have a workaround to get the behaviour I wanted. Maybe people hitting the same issue will find this issue in their googling and save them some time or at least they'll know they're not alone. Hopefully one day the weird BrowseOnly behaviour is understood or even fixed.
Thanks for pointing out #11 too. I hadn't found it as I had been looking for the info on the first/main issue.
@mwrock
Do you have at hand parameter set that can be used to install ALL updates, not just critical and security updates ?