Finding Missing Updates

by Jun 13, 2019

PowerShell can access the same logic that is used by the Windows Update Client, and query for missing updates:

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

Here is a more sophisticated approach returning update title and KB number (if available):


$UpdateSession = New-Object -ComObject Microsoft.Update.Session
$UpdateSearcher = $UpdateSession.CreateupdateSearcher()
$Updates = @($UpdateSearcher.Search("IsHidden=0 and IsInstalled=0").Updates)
$Updates | 
ForEach-Object {
    $pattern = 'KB\d{6,9}'
    if ($_.Title -match $pattern)
    {
        $kb = $matches[0]
    }
    else
    {
        $kb = 'N/A'
    }
    [PSCustomObject]@{
        Title = $_.Title
        KB = $kb
    }
} | Out-GridView 

Twitter This Tip! ReTweet this Tip!