Running a Powershell Script via a Scheduled Task

This blog post will show how to run a Powershell Script via a Scheduled task on a Windows 2008 R2 Server.

 

On your Windows 2008 Server, or Windows 7 machine. Open the Start Menu and then type in 'task' into the start search field. Then select Task Scheduler.

Select Create Basic Task. In the Actions Pane on the right hand side of the screen.

Type in a Name and a description for the Scheduled Task. Once done, click Next.

Set how often you would like the task to run. Then click Next.

Select Start a Program. This is so we can kick off the powershell.exe. Click Next.

In the program field type:

Powershell.exe

 

In the add arguments field type:

-Noninteractive -NoProfile -command "& '<path to .ps1 file>'"

 

Click Next.

Tick the Open the Properties check box then click Finish.


 

Go through each individual tab if you need to.

 

On the general tab, make sure you set the appropriate user to run the script.

 

Be sure to take into consideration whether you want the script to run only when a user is logged in or not.

Check the Triggers tab.

Check the Actions tab.

Check the conditions page and set any conditions you may want to put on the task.

Double check the setting page. And then click ok.

Put in the credentials you would like to run the scheduled task under.

The task is now set to run. This will now execute your powershell script at the time and date that you specified.

 

YOU WIN!

Tagged , , . Bookmark the permalink.