<# .SYNOPSIS This script obtains the UpdateID of the Windows update program based on scanning local computer. .DESCRIPTION This script use Windows Update Agent API online scan or offline scan (if wsusscn2.cab is downloaded) to get availables update and it's UpdateId. .INPUTS The script takes no parameter. .OUTPUTS List of UpdateIDs and titles for update programs. .EXAMPLE # Online scan .\get-updateidsbyscan.ps1 .EXAMPLE # Offline scan (you have to run as administrator) $ProgressPreference = 'SilentlyContinue' Invoke-WebRequest -uri "https://catalog.s.download.windowsupdate.com/microsoftupdate/v6/wsusscan/wsusscn2.cab" -outfile "$env:userprofile\Downloads\wsusscn2.cab" $ProgressPreference = 'Continue' .\get-updateidsbyscan.ps1 .NOTES This script is a sample. Use it at your own risk. #> $scancabPath = "$env:userprofile\Downloads\wsusscn2.cab" $UpdateSession = New-Object -ComObject Microsoft.Update.Session if (Test-Path $scancabPath) { $UpdateServiceManager = New-Object -ComObject Microsoft.Update.ServiceManager $UpdateService = $UpdateServiceManager.AddScanPackageService("Offline Sync Service", $scancabPath) $UpdateSearcher = $UpdateSession.CreateUpdateSearcher() $UpdateSearcher.ServerSelection = 3 # ssOthers $UpdateSearcher.ServiceID = [string] $UpdateService.ServiceID } else { $UpdateSearcher = $UpdateSession.CreateUpdateSearcher() } $searchResult = $updateSearcher.Search("IsInstalled=0 and Type='Software' and IsHidden=0") if ($searchResult.Updates.Count -eq 0) { Write-Host "There are no applicable updates." } else { $i = 0 foreach ($update in $searchResult.Updates){ $i++ Write-Host $i">" $update.Title Write-Host " Suport URL:" $update.SupportUrl Write-Host " Update ID :" $update.Identity.UpdateID Write-Host "" } }