Using Windows Task Scheduler to automatically run PowerShell scripts

Windows PowerShell scripting is a powerful way of automating otherwise tiresome and error prone manual tasks. I recently looked into how I could have Windows running my scripts for me. It is not difficult, but it still took some poking around to get done.

The Windows Task Sheduler in the Start Menu

New tasks are added using the Create Task option in the Actions area.

Windows Task Sheduler Actions Panel

The General tab will let you decide how you want the task to be run; you may for instance set user privileges and what system you want to run it on.

Windows Task Scheduler General Tab

The Triggers tab is where you specify when to run the PowerShell script. Of course this does not need to be a specific time, you may also use other triggering events.

Windows Task Scheduler New Trigger

The Actions tab is where the interesting parts are. In order for your PowerShell script to run, you must first specify the program that will run it; i.e. powershell.exe. Unless this is already in your Path-variable, you will have to add the full path. For instance, %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe. The Add arguments (optional) field is where you will specify where your script is located; -Noninteractive -Noprofile -Command “&{D:\SampleCode\Scripts\script.ps1}”

Windows Task Scheduler New Action

The task are found in the Task Sheduler Library.

Windows Task Scheduler Library

This entry was posted in Automation, Powershell script, Windows tools and tagged automation, Powershell, script, Windows Task Sheduler. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>