Task Scheduler to run PowerShell

Copper Contributor


I have a windows PowerShell Script that I made to move a folder to anther folder on the same drive. (move-item 'E:\System State Folder' 'E:\Backup Folder') Action : Start a Program, Program/script: PowerShell, Add arguments: -ExecutionPolicy Bypass, Start in: C:\Users\Administrator\Desktop\Test.ps1

PowerShell opens but the folders do not move.

7 Replies

you forgot "-file" argument where you set path to your PS script. Please read more here https://blogs.technet.microsoft.com/heyscriptingguy/2012/08/11/weekend-scripter-use-the-windows-task...

And you might also need to run the script as administrator. In any case, add some logging/debugging capabilities in the script in order to troubleshoot it properly.

I have in the task scheduler run as administrator but still nothing, I can run the script by using the open with PowerShell and it will work. Just cant get the darn to work as a task.

Paul, as I mentioned you are mising "-file" parameter, as from the script I see that you have mixed it with "-Start in" as this should be the directory where the script should run and not the path to your script as this parameter is optional

Sorry I didn't see your post earlier I will give it a try

It works great thanks for the quick response . 

I wrote a blog post in March on how to use task scheduler to run PowerShell scripts with arguments: https://www.andersrodland.com/powershell-script-with-arguments-as-a-scheduled-task/