In your invoke web request just use the parameter -UseBasicParsing
e.g. in your script (line 2) you should use:
$rss = Invoke-WebRequest -Uri $url -UseBasicParsing
According to the documentation, this parameter is necessary on systems where IE isn't installed or configured:
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.
To make it work without modifying your scripts:
I found a solution here: http://wahlnetwork.com/2015/11/17/solving-the-first-launch-configuration-error-with-powershells-invoke-webrequest-cmdlet/
The error is probably coming up because IE has not yet been launched for the first time, bringing up the window below. Launch it and get through that screen, and then the error message will not come up any more. No need to modify any scripts.
You can disable need to run Internet Explorer's first launch configuration by running this PowerShell script, it will adjust corresponding registry property:
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Internet Explorer\Main" -Name "DisableFirstRunCustomize" -Value 2
After this, WebClient will work without problems
It is sure because the Invoke-WebRequest command has a dependency on the Internet Explorer assemblies and are invoking it to parse the result as per default behaviour. As Matt suggest, you can simply launch IE and make your selection in the settings prompt which is popping up at first launch. And the error you experience will disappear.
But this is only possible if you run your powershell scripts as the same windows user as whom you launched the IE with. The IE settings are stored under your current windows profile. So if you, like me run your task in a scheduler on a server as the SYSTEM user, this will not work.
So here you will have to change your scripts and add the -UseBasicParsing argument, as ijn this example: $WebResponse = Invoke-WebRequest -Uri $url -TimeoutSec 1800 -ErrorAction:Stop -Method:Post -Headers $headers -UseBasicParsing
In Windows 10, where after Edge is installed by the OS (and IE not used at all -- as many users just prefer Chrome after a fresh Windows install), when trying to run a script from localhost using
curl http://localhost:3000/
the same error message is received -- as the one Luis mentioned, followed by this one:
+ curl http://localhost:3000/ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotImplement ed: (:) [Invoke-WebRequest], NotSuppor tedException + FullyQualifiedErrorId : WebCmdletIED omNotSupportedException,Microsoft.Powe rShell.Commands.InvokeWebRequestComman d
If you use instead
Invoke-RestMethod http://localhost:3000/
the code will work as intended.
I did not try to replicate Luis exact code, however it's still a use case that worked for me.
Also, because the question was asked more than 5 years ago and a best answer was chosen, I decided to still let my answer here just for readers that can use it in another scenario, too (for example when running a code in nodejs and opening a second terminal to test it faster instead of opening a new browser instance)
In your invoke web request just use the parameter -UseBasicParsing
e.g. in your script (line 2) you should use:
$rss = Invoke-WebRequest -UseBasicParsing
According to the documentation, this parameter is necessary on systems where IE isn't installed or configured.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With