Powershell – How to schedule a PS1 script with Scheduled Tasks

I was recently working on a project where I needed to schedule a Windows Powershell script to run. After some searching, I came across a post that lead me in the right direction at Mutable.net. Here is how you can schedule a Windows Powershell Script:

The first thing you need to do is make sure that Powershell is set to execute Powershell scripts, instead of only allowing interactive commands to be run in the Powershell environment.

Type the following at the Powershell command prompt:

set-executionpolicy RemoteSigned

This will allow the system to run Powershell scripts that are created locally (Remote Powershell scripts that may be downloaded must be signed).

Once this is done, you can create your Powershell script using notepad. Just make sure you name the file with an extension of .ps1 . Now to run the script outside of its Powershell environment you type a command similar to the following:

powershell -command "& 'MyScript.ps1' "

Just put the above command into a .bat or .cmd file and schedule it like you would normally schedule a script to be run with Windows Task Scheduler.

Happy coding!