PowerShell Invoke-WebRequest Error

Problem

I have setup a scheduled task to run powershell to post to web api as UserX.

When I login as UserX and run the following in command prompt:

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.EXE “Invoke-WebRequest -Method POST http://api.xxxxx.com/api/v1/xxxx/xxxxx

It returns the following error:

C:\Users\xxxx>C:\Windows\System32\WindowsPowerShell\v1.0\powershell.EXE "Invoke
-WebRequest -Method POST http://api.xxxxx.com/api/v1/xxxx/xxxxxx"

Invoke-WebRequest : The response content cannot be parsed because the Internet
Explorer engine is not available, or Internet Explorer's first-launch
configuration is not complete. Specify the UseBasicParsing parameter and try
again.
At line:1 char:1
+ Invoke-WebRequest -Method POST
http://api.xxxxx.com/api/v1/xxxx/xxxxxx ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~
+ CategoryInfo : NotImplemented: (:) [Invoke-WebRequest], NotSupp
ortedException
+ FullyQualifiedErrorId : WebCmdletIEDomNotSupportedException,Microsoft.Po
werShell.Commands.InvokeWebRequestCommand

 

Solution

In my case, login as UserX and launch Internet Explorer and setup the initial configuration.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s