While setting up a batch server to run PowerShell scripts via the Task Scheduler, I ran into a snag with one particular service account that was failing to run the Invoke-WebRequest cmdlet. Looking at the job details, I saw this specific error being thrown:
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.
For this service account, the error was correct – I had never logged in and run Internet Explorer. As a reminder, the first launch screen is the one asking you about Internet Explorer settings for security, privacy, and compatibility.
I essentially ignored the advice to set the UseBasicParsing parameter, because in many cases that isn’t an option and it would be silly to edit all of my cmdlets just for this. Having to walk through this set up screen on every computer that may ever need to run a service account would be crazy. Automation is clearly the answer.
Configuring a Group Policy Object
I’ve opted to use a Group Policy Object (GPO) to handle the first run wizard. I’ve included a screenshot of the GPO setting below – it’s in Computer Configuration > Policies > Administrative Templates > Windows Components > Internet Explorer. Set the policy to Enabled and pick an option that suits you (I chose to go to the home page).
Practice proper GPO creation by toggling the GPO Status to User configuration settings disabled. This is because there are no user configuration settings specified in this GPO. Properly setting the GPO Status will have a positive impact on your GPO update run times.
As a test, I ran gpupdate /force on the batch server and then tried my cmdlet again. Here’s a screenshot showing
- The Connect-Rubrik cmdlet fails with the first run error.
- I trigger a group policy update using the command prompt.
- A second attempt at the Connect-Rubrik cmdlet with Internet Explorer’s First Run having been disabled.
Success! I hope this helps anyone else looking to use the Task Scheduler to run PowerShell cmdlets that invoke a RESTful API.
Please accept a crisp high five for reaching this point in the post!