Powershell Invoke-WebRequest to https://docs.microsoft.com

Fischer, Matthias 6 Reputation points
2021-03-24T12:16:28.217+00:00

Hi guys,
we tried to invoke a webrequest with powershell to https://learn.microsoft.com (https://learn.microsoft.com/en-us/officeupdates/update-history-microsoft365-apps-by-date) to get the versionnumber table for exchange via ps1 script. It worked fine since today.
Now all invoke-webrequest to learn.microsoft.com without basic parsing seems to be blocked with powershell running into an endless loop without error. Anyone else got problems like this?
Thanks!

Windows for business | Windows Server | User experience | PowerShell
0 comments No comments
{count} votes

12 answers

Sort by: Most helpful
  1. Douglas Baker 1 Reputation point
    2022-06-09T23:22:12.633+00:00

    Is this issue still a thing/ is it back? i have been stuggling all of a sudden with a script i use to keep up to date and no matter what i do if i try to access docs with powershell it errors out.

    0 comments No comments

  2. Paul 1 Reputation point
    2022-06-10T08:38:01.303+00:00

    Its still working for me. Here is a snippet of the code I use if it helps you:

    $HTML = Invoke-WebRequest -Uri "https://learn.microsoft.com/en-us/officeupdates/update-history-microsoft365-apps-by-date"
    $parsedcontainer = $HTML.ParsedHtml.getElementsByTagName('tr') | Where {$.innerHTML -notmatch "Preview" -and $.innerHTML -match "Semi-Annual Enterprise Channel" -and $_.innerhtml -match "2102"} | select innerhtml
    $latestversion = $parsedcontainer.innerhtml
    $String = $latestversion
    $Regex = [Regex]::new("(?<=13801)(.*)(?=<)")
    $Match = $Regex.Match($String)
    $latestversion = '16.0.13801' + ($Match.value.Split('<') | Select -First 1)

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.