Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Invoke-WebRequest causes IE content blocked dialog

On a Windows server with Internet Explorer Enhanced Security Configuration enabled, calling Invoke-WebRequest like this:

Invoke-WebRequest "http://localhost" -UseBasicParsing -UseDefaultCredentials

Results in this error dialog:

Internet Explorer dialog - Content within this application coming from the website listed below is being blocked by Internet Explorer Enhanced Security Configuration

Considering that this script is intended to be run remotely, I'd like to avoid the dialog appearing at all.

like image 223
David Gardiner Avatar asked Sep 16 '14 07:09

David Gardiner


3 Answers

It seems Invoke-WebRequest requires IE unless you specify -UseBasicParsing parameter. see: https://msdn.microsoft.com/powershell/reference/5.1/microsoft.powershell.utility/Invoke-WebRequest

-UseBasicParsing Indicates that the cmdlet uses the response object for HTML content without Document Object Model (DOM) parsing.

This parameter is required when Internet Explorer is not installed on the computers, such as on a Server Core installation of a Windows Server operating system.

like image 108
Patrik Lindström Avatar answered Nov 11 '22 11:11

Patrik Lindström


Perhaps systems have changed since Raf's answer above was posted. I found it didn't work for me.

What did work was:-

  1. Open Internet Explorer
  2. Go to Tools->Internet options
  3. Select the Security Tab
  4. Click Local Intranet
  5. Click sites
  6. Enter *.security_powershell.exe
  7. Click Add
like image 22
Mick Avatar answered Nov 11 '22 10:11

Mick


Click Add and add about:security_powershell.exe to Trusted Sites.

like image 7
Raf Avatar answered Nov 11 '22 12:11

Raf