1

I have a PowerShell script set to run daily as a scheduled task, it is setup with an action of: Run Program PowerShell.exe Arguments: -executionpolicy bypass -file D:\Scripts\SomeScript.ps1

The script completes successfully and in task manager I can see PowerShell start then close, but Task Scheduler still shows it Running.

Any suggestions on how to fix this?

1

Even though the script was doing everything it was configured to it seems I needed to place all of the arguments inside quotes.

Old arguments (everything completed fine but task hung): -executionpolicy bypass -file 'D:\Scripts\SomeScript.ps1'

New arguments (everything still completes fine including the Task): "-executionpolicy bypass -file 'D:\Scripts\SomeScripts.ps1'"

Not sure why this one server is requiring quotes, I run this exact script on multiple servers running the save version of Windows and same version of PowerShell, NONE of them have the quotes, but it works.

  • mark it answered – Xalorous Aug 30 '16 at 2:20
1

Just a tiny note: If you run a task manually it will go to "running" in task scheduler library. Wait until your task finishes and then hit F5 to refresh.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.