Powershell – Running a Powershell script from a scheduled task

Scheduling scripts is a big part of a automation but you may be struggling to get your scripts working using the native task scheduler. This post covers how to get past the initial hurdles.

Step 1 – Open Task Scheduler and create a new task

step1

Step 2 – Name the task, and set the security options (use an account that has the permissions to run your script and the commands within it, unless you are using the -Credentials parameter on your commandlets)

step1

Step 3 – Set your triggers

I have set mine to hourly in this example.

step3

Step 4- Set your actions

You will want to start a program, and that program will be Powershell. You will also pass the script that you want to run as an argument for Powershell to run when the schedule is triggered.

Program/script: C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe

Add arguments: -File “C:\Web\Scripts\EUCTools\Dashboard\EUC_TestCSFederatedPartner_Schedule.ps1”

Start in: C:\WINDOWS\system32\WindowsPowerShell\v1.0

step4

Step 5 – Completion

You can leave the rest as is and save your changes. You will now have a schedule that will run your Powershell script!

step5

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s