PS – The new theme for jaredheinrichs.com should be up within the next two weeks.
Couple of things to know
There are two main things that you have to do to schedual Powershell scripts.
- Allow Interactive Commands using set-executionpolicy command.
- Put Powershell script in a ".ps1" file. You can use any text editor to make this.
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:
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.