Quick Tips #3: Check your PowerShell Sheduled Tasks with CMD
I was migrating some scheduled PowerShell scripts to a new application server (Windows Server 2016), and was having trouble getting them to run from Task Scheduler.
I tried changing the service account used, the path to the script file, the path to the PowerShell executable, the execution policy etc. All to no avail, the scripts just would not run from the task scheduler.
I decided to take a step back, and manually trigger the PowerShell scripts from CMD, which is what this tip is all about. Firstly, it eliminates from the equation the many variables in Task Scheduler itself, and more importantly, it will give you some feedback in the CMD window as to what the error is.
Here was mine, as much as I hate to share it:
Yup…on the new server, with file extensions hidden, I didn’t realise I had renamed the scripts to scriptname.ps1.ps1, with the Scheduled Task targeting scriptname.ps1.
Still, nice troubleshooting step to take if your Scheduled Tasks aren’t running, as there is often limited feedback from the Task Scheduler History pane.