Running a PowerShell script as scheduled task is not as easy as entering PowerShell.exe *script name.ps1*. I have been struggling with it for quite some time.
Here is a command line to get it up and running:
1) Set the execution policy so script are allowed to run, open PowerShell and enter:
Set-executionpolicy -scope currentuser -executionpolicy unrestricted
Choose Y (Yes) to allow scripts to run.
2) Next open scheduled task and enter:
powershell.exe -command "& ‘C:\My Scripts\Backup.ps1’ "
change the name of the script to the name of your script.
Now the script will run on the chosen date and time.
Can’t get the solution to work? Contact me and let me do the trick.