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. Paul 1 Reputation point
    2021-04-06T08:40:08.813+00:00

    Anyone noticed that IWR seems to not work again?


  2. António Pedro Pinho 6 Reputation points Microsoft Employee
    2021-04-19T08:29:38.837+00:00
    0 comments No comments

  3. Paul 1 Reputation point
    2021-04-19T08:44:31.61+00:00

    I've just gotten a resolution from Microsoft and it mirrors what is seen in @Anonymous 's post.

    Add a DWORD value of "PowerShell.exe" and/or "PowerShell_ISE.exe" with a value of "00002af9" to the following location. You must restart for this to take effect.

    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION

    or

    HKEY_CURRENT_USER\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION

    I am guessing that @Anonymous is from Microsoft as in the example the same URL that I supplied as a problem in the ticket is used!.

    This will work with either of these examples:

    1 - Without UseBasicParsing enabled

    Invoke-WebRequest -Uri "https://learn.microsoft.com/en-us/windows-server/remote/remote-desktop-services/clients/windowsdesktop-whatsnew"

    2 - with BasicParsing (which may come in handy if PowerShell 7 becomes the norm

            $page = Invoke-WebRequest -Uri "https://learn.microsoft.com/en-us/windows-server/remote/remote-desktop-services/clients/windowsdesktop-whatsnew" -UseBasicParsing  
            # Create HTML file Object  
            $HTML = New-Object -Com "HTMLFile"  
            # Write HTML content according to DOM Level2   
            $HTML.IHTMLDocument2_write($page.Content)  
            $HTML.getElementsByTagName('h2') | select id | Where{ $_.id -match "updates-for-version" -and $_.id -notmatch "insider"} | select -first 1  
    

  4. António Pedro Pinho 6 Reputation points Microsoft Employee
    2021-04-19T10:12:14.867+00:00

    That's correct Paul, I've investigated this issue late last week and my findings/testing are included in the mentioned GitHub issue. Even though this will be fixed at the site level any time soon (see https://github.com/microsoft/DynamicProto-JS/issues/31), we'll be working internally to see how can we improve this scenario so we hopefully do not hit this issue type again.


  5. Paul 1 Reputation point
    2021-04-28T14:45:18.653+00:00

    This is now resolved! Had confirmation from MS and I've tested myself.

    You DO NOT need the additional keys defined in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION

    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.