Scheduling Scripts On Windows 10
The Task Scheduler application allows automating power shell scripts. This guide will show you the steps to create and schedule your first script.
Steps to create a power shell task:
Go to
Start
and search forTask Scheduler
and open it.Click the
Action
->Create Task
from the menu bar.Give a suitable
name
and an optionaldescription
for this task. TheSecurity Options
section can be used to configure which administrator account can run the task.In order to run a power shell script without the command window from showing up, we need to select the option
Run whether user is logged on or not
in theSecurity Options
as shown above.Now navigate to the
Triggers
tab -> and select theNew
button. Select action to be a program- The
Begin the task
option can be used to set at what event the task must execute (If it were to start on system log on, based on a schedule or when the system gets locked/unlocked). - The
Settings
section (Outlined green) allows one to set the time on which the task must be run. A task can be set to run on a given time, or can be set to run daily, weekly on specific days or even several days on every given month. - The
Advanced settings
section (Outlined Cyan) allows one to set the frequency of running tasks, restrictions on when to stop the task and even an expiry rule for the task.
- The
Now navigate to the
Actions
tab -> and select theNew
button. In theProgram/script
field mention the path to thepowershell.exe
. You can add the complete path to the actual power shell script to theAdd arguments
field.The
Conditions
tabs can be used to set more specific conditions apart from the trigger, to determine whether the task should run. The task will not run if any condition specified in this tab is not true.And the
Settings
tab can be used to specify any other additional behavior of the task such as when to delay, repeat, stop, and expire the task. (Usually, I don't change these settings unless necessary)Click on the
OK
button to save the task.
Steps to enable, disable, edit and delete a task:
Go to
Start
and search forTask Scheduler
and open it.To enable or disable a task, right click on the task from the list of tasks and click on either
Enable
/Disable
option from there.To edit the task, right click on the task from the list of tasks and click on
Properties
option from there. This will open up the task window and you can change the task properties there.To Delete a task, right click on the task from the list of tasks and click on
Delete
option from there.
And that's about it folks, you have scheduled your first power shell script. Although this guide is focused on scheduling power shell scripts in Windows 10, the same should work with older versions of Windows that have the task scheduler.