Skip to content

Instantly share code, notes, and snippets.

@Grimthorr
Created November 9, 2015 16:03
Show Gist options
  • Save Grimthorr/44727ea8cf5d3df11cf7 to your computer and use it in GitHub Desktop.
Save Grimthorr/44727ea8cf5d3df11cf7 to your computer and use it in GitHub Desktop.
PowerShell script to list the pending/missing Windows updates.
$UpdateSession = New-Object -ComObject Microsoft.Update.Session
$UpdateSearcher = $UpdateSession.CreateupdateSearcher()
$Updates = @($UpdateSearcher.Search("IsHidden=0 and IsInstalled=0").Updates)
$Updates | Select-Object Title
@fliespl
Copy link

fliespl commented Sep 25, 2021

@pratyakshm

You can find it like that:

$UpdateSession = New-Object -ComObject Microsoft.Update.Session
$UpdateSearcher = $UpdateSession.CreateupdateSearcher()
$Updates = @($UpdateSearcher.Search("IsHidden=0 and IsInstalled=0").Updates)
$Updates | Where-Object IsMandatory -eq $true | Select Title, IsMandatory

@aymenjaz
Copy link

Thanks

@pratyakshm
Copy link

Thanks @fliespl! ❤️

@Kein
Copy link

Kein commented Apr 28, 2022

This appears to be actually skipping optional/recommended updates. I have update preview kb5011831 pending in WU on W10LTSC 21H2 19044.1348 but it is not in the list generated by UpdateSearcher. I've tried supplying empty criteria - still the same result. It does ignore the group policy for "skip drivers in WU" which is nice.

@guillerg86
Copy link

If u need to read from a software like Zabbix or just load in some api or application you can use this

https://github.com/guillerg86/zabbix/blob/main/scripts/windows/powershell/wu-get-mandatory-updates.ps1

@mrbaraclough
Copy link

Thanks, this was perfect!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment