<# .SYNOPSIS This script obtains the Download URL and FILENAME of the Windows update program that have specified UpdateID. .DESCRIPTION This script web scrapes the DownloadDialog page of the Microsoft Update Catalog site (https://www.catalog.update.microsoft.com/DownloadDialog.aspx) to obtain the URL and FILENAME for UpdateID. .INPUTS The script takes UpdateId. .OUTPUTS List of URLs and FILENAMES for Updateid's update programs. .EXAMPLE # Get URL and FILENAME that have UpdateID "244bab40-f647-4394-bee0-b03f897404d8" .\get-downloadlinks.ps1 -UpdateId "244bab40-f647-4394-bee0-b03f897404d8" .EXAMPLE # Get URL and FILENAME that have UpdateID "244bab40-f647-4394-bee0-b03f897404d8" $links = .\get-downloadlinks.ps1 -UpdateId "244bab40-f647-4394-bee0-b03f897404d8" $links.URL $links.FILENAME .NOTES This script is a sample. Use it at your own risk. #> Param($UpdateId) if ($PSBoundParameters.Count -ne 1) { Write-host "Error: -UpdateId " ;exit 1} $PostJson = @{size = 0; UpdateID = $UpdateId; UpdateIDInfo = $UpdateId} | ConvertTo-Json -Compress $Body = @{UpdateIDs = "[$PostJson]"} $ret = Invoke-WebRequest ` -Uri 'https://www.catalog.update.microsoft.com/DownloadDialog.aspx' ` -Method Post ` -ContentType 'application/x-www-form-urlencoded' ` -Body $body $pattern = "downloadInformation\[\d+\]\.files\[\d+\]\.url\s*=\s*'([^']+)'" $items = [regex]::Matches($ret.Content, $pattern) | ForEach-Object { $url = $_.Groups[1].Value [pscustomobject]@{ URL = $url FileName = Split-Path $url -Leaf } } | Sort-Object URL -Unique $items