<# .SYNOPSIS This script obtains the UpdateID of the Windows update program (KB#######). .DESCRIPTION This script web scrapes the search results page of the Microsoft Update Catalog site (https://www.catalog.update.microsoft.com/Search.aspx) to obtain the UpdateID of the update program. .INPUTS The script takes KBnumber or any keyword. .OUTPUTS List of UpdateIDs and titles for update programs. .EXAMPLE # Get the UpdateID and title of update KB5063878. .\get-updateids.ps1 -KB KB5063878 .EXAMPLE # Get the UpdateID and title of update using keyword "2025-08 .NET Update". .\get-updateids.ps1 -KB "2025-08 .NET Update" .NOTES This script is a sample. Use it at your own risk. #> Param($KB) if ($PSBoundParameters.Count -ne 1) { Write-host "Error: -KB KB999999" ;exit 1} $searchstr = "https://www.catalog.update.microsoft.com/Search.aspx?q=$($KB)" $ret = Invoke-WebRequest -Uri $searchstr if ($ret.StatusCode -eq "200"){ $pattern = @' (?is)]*onclick\s*=\s*(["']?)goToDetails\(\s*"([0-9A-Fa-f-]{36})"\s*\)\s*;?\s*\1[^>]*>\s*(.*?)\s* '@ $items = [regex]::Matches($ret.Content, $pattern) | ForEach-Object { $guid = $_.Groups[2].Value $raw = $_.Groups[3].Value $text = ($raw -replace '<[^>]+>','') $text = [System.Net.WebUtility]::HtmlDecode($text) $title = ($text -replace '\s+',' ').Trim() [pscustomobject]@{ UpdateId = $guid; Title = $title } } | Sort-Object UpdateId -Unique return $items } else { Write-Error -Message "HTTP Status Code: $($ret.StatusCode)" return $null }