I have installed the Windows task scheduler and noticed that it will not run successfully. The switch from curl.exe to invoke-webrequest causes an issue with execution policy. The command runs from a normal powershell window but will not run as an scheduled task. I have set every switch I can think of to get around the exectution failure but haven't been successful. Any ideas on how ot get this to work so I don't have to updated the action on every task to point it back to curl.exe?
Developer forum
E-mail notifications
Windows Scheduled task last run result 0x1
Replies
Actually, the error in Task Scheduler is misleading. Checking the logs, the tasks are running. Sorry for the firedrill.
Isn't it still an error then? Would it make sense to post the error so the development team can take a look?
Could be execution profile... Did you try one or more of these?
powershell.exe -NoProfile -NoLogo -NonInteractive -ExecutionPolicy Bypass
Hi Nicolai,
I tried all those switches except for -NoLogo previously and got the error. I just ran it with all of those and still get a last run result of 0x1. It is definitely the Execution Policy from what I have been able to narrow down. If I set a user that isn't System, it will complete successfully.
So, it might be related to some Windows things that are over my paygrade... I'll ask our service desk if they know what to do.
BR Nicolai
The webrequest uses the IE engine for processing request/response, and maybe you run into some security/policy restrictions for IE. Try and add a -UseBasicParsing parameter to the parameter list. This will ditch IE for processing. Downside is that plain text (no DOM) is returned - but that should be all good in this context. Try it out and let me know if there was success.
Best regards
Morten
Winner Winner Chicken Dinner. That was the needed switch Morten. I didn't even think about the IE engine.
You must be logged in to post in the forum