I'm trying to run a PowerShell command via Task Scheduler but keep getting the below result when the task tries to run PowerShell on my Windows Server 2008 R2 environment.
action "powershell.exe" with return code 1.
When I run the script in PowerShell manually, the script runs. But for some reason, when I call it from the Task Scheduler it doesn't run.
A screenshot of how my action is set up is attached below.
I've made sure to do the following:
I'm fresh out of ideas.
Figured this one out thanks to some help from @TheIncorrigible1.
The issue was that the Start In field on the task scheduler was set to a path with a root directory other than C:
To resolve, I left Start In blank and in the Add Arguments field I called the script file with a full file path.
Instead of the below in the Add Arguments field
.\csv-convert.ps1
I referenced the script as follows :
D:\mypath\csv-convert.ps1
Bottom line, dont start powershell in a path with a directory other than C: