Created
July 28, 2023 13:03
-
-
Save abbodi1406/d061bb3ac22a015947414ef988053eef to your computer and use it in GitHub Desktop.
Get updates' UpdateID from Microsoft Update Catalog
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Param( | |
[parameter(Mandatory)][string]$KBnumber, | |
[string]$arch, | |
[string]$vers | |
) | |
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Enum]::ToObject([Net.SecurityProtocolType], 3072) | |
$ProgressPreference = 'SilentlyContinue' | |
$search = Invoke-WebRequest -Uri ("https://www.catalog.update.microsoft.com/Search.aspx?q={0}" -F $KBnumber) -Headers @{"Accept-Language"="en-US;q=0.8,en;q=0.6"} | |
$document = $search.ParsedHtml | |
$table = $document.GetElementById('ctl00_catalogBody_updateMatches') | |
if ($null -ne $table) { | |
foreach ($row in $table.GetElementsByTagName("TR")) { | |
$cols = $row.GetElementsByTagName("TD"); | |
if ($null -eq $cols) {continue} | |
if ($null -eq $cols[2].InnerText) {continue} | |
$title = $cols[1].InnerText | |
if ($title -match "Dynamic Cumulative") {continue} | |
if ($null -ne $vers) { | |
if ($title -notmatch $vers) {continue} | |
} | |
if ($null -ne $arch) { | |
if ($title -match "x64") { | |
if ($arch -eq "x86") {continue} | |
if ($arch -eq "ARM64") {continue} | |
} elseif ($title -match "ARM64") { | |
if ($arch -eq "x86") {continue} | |
if ($arch -eq "x64") {continue} | |
} else { | |
if ($arch -eq "x64") {continue} | |
} | |
} | |
($cols[7].GetElementsByTagName("INPUT")[0]).id | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Examples: