#$links = .\get-downloadlinkswithhash.ps1 -UpdateId "244bab40-f647-4394-bee0-b03f897404d8" #$links.URL #$links.FILENAME 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' ` -UseBasicParsing ` -Method Post ` -ContentType 'application/x-www-form-urlencoded' ` -Body $body $pattern = "files\[(\d+)\]\.(url|digest|sha256)\s*=\s*'([^']+)'" $map = @{} foreach ($m in [regex]::Matches($ret, $pattern)) { $idx = [int]$m.Groups[1].Value $key = $m.Groups[2].Value $val = $m.Groups[3].Value if (-not $map.ContainsKey($idx)) { $map[$idx] = [ordered]@{ Index = $idx url = $null digest = $null sha256 = $null fileName = $null } } $map[$idx][$key] = $val if ($key -eq 'url') { $map[$idx]['fileName'] = [System.IO.Path]::GetFileName($val) } } $items = $map.GetEnumerator() | Sort-Object Key | ForEach-Object { [pscustomobject]$_.Value } $items