How to Create Scheduled Task Using PowerShell

The task list for a majority of system administrators includes writing various scripts and launching them. Scheduling the launch of the script using the graphical interface of the Task Scheduler console is a quite simple task. In this small article we’ll show you a new way to create scheduled task using the PowerShell console.

Suppose you need to create a task that will run the PowerShell script every Tuesday and Thursday at 10:00 PM.

In order to create a new scheduled job on Windows 7 and older versions you must have at least PowerShell 3.0 installed. At first, you need to run elevated PowerShell command prompt and import PowerShell module named PSScheduledJob.

Import-Module PSScheduledJob

Now let’s create a new job trigger:

$Trigger = New-JobTrigger -Weekly -DaysOfWeek 2,4 -At 10:00PM

After that create a new task named BackupDBTask and bind the created trigger to it:

As you can see, the new scheduled task was successfully created. You can find it using Task Scheduler GUI in the following section: Task Scheduler -> Task Scheduler Library -> Microsoft ->Windows -> PowerShell -> SheduledJobs.

When creating a new job, PowerShell additionally generates an xml file with a scheduled task definition. You can find this file in the folder: