Tuesday, May 31, 2016

Powershell Invoke-Webrequest error "Internet Explorer engine is not available"

We encountered the following error in an SSIS job that launched a PowerShell script, and the job was executing (we thought) successfully.  There was, though, zero output.  A couple of things going on here, then.

First, the error:
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.

Now, why wouldn't we have gotten that error in our testing, or in our logs?
That, it turns out is two separate questions. 
We didn't get it in our testing, because we were testing as interactive users, and those interactive users had launched IE.  So no problem.

Our service account--as a matter of course--has never logged in interactively on the server.  So that user never launched IE.  The error, then, gave us the solution, as well (as errors ought):  use the -UseBasicParsing parameter with invoke-webrequest.

When we add the -UseBasicParsing parameter (invoke-webrequest $URL -UseBasicParsing), all worked well.

Why didn't this cause my job to fail?

Ah, now there's a problem worth addressing.  This *was* in fact an error, and we normally would want such errors to result in, well, an error.
PowerShell, however, has different classes of errors, and this one isn't a terminating error.  So PowerShell sees it as an error, but PowerShell still exits cleanly, and so it's runstatus at the end is zero (success).

See this post for some details on fixing that particular problem.

No comments:

Post a Comment

Thanks for leaving a comment!