top of page
Search
  • Writer's pictureMaarten Boonen

Scheduling a PowerShell Script


I was asked by a colleague how to schedule a PowerShell script on a Windows server. Although this is not rocket science there are a few hoops you need to jump through in order to accomplish it.

Steps to schedule

Any PowerShell script can be scheduled.

Open the Task Scheduler which resides under the Windows Administrative tools. You will be presented with a common Windows maintenance layout application. Some navigation on the left, the action panel on the right and in the middle the stuff you need to focus on.

Click the Create Task link and a window with a few tabs will appear.

General

Name your Script and modify the Security options as below.

For the account which is running the script I recommend to use a Domain service account you create yourself and add to the local administrators group (BUILTIN\Administrators) of the server. Remember to make sure the password of the account will not expire.

Triggers

On the triggers tab we tell the task when to get triggered to run. In this example every day at 05:00 am. The most important thing on this tab is the enable checkbox. You need to make sure every time you open or modify the task this box stays enable in order to run.

Actions

On the Actions tab we tell the task what to do. In this case to run PowerShell and associate a script to run.

Program/script

The PowerShell.exe application can be found in the following location on any Windows OS.

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe

Arguments

The Arguments option will be the path to the script including the name of the script. In this example the script is stored on C:\PowerShell_Scripts\awesome.ps1

Start in

This will be the folder where you want the script to start from just keep it similar to the location of the script without the script name itself, C:\PowerShell_Scripts

Conditions

Just keep it default.

Settings

Just keep it default.

Click right and Run to test it. It’s recommended to check the next day the script worked as expected. If you make any modifications to the script double check on the Tiggers tab >> Edit Trigger if the Enable checkbox is still flagged.

Nice video about the whole process

Jack Fruh made a nice clear little video about the process which is even better than my screenshots.

80 views
bottom of page