How to create scheduled tasks with PowerShell on Windows 10
On Windows x, the Chore Scheduler is a useful tool that has been around for many years, and it provides a friendly graphical interface to create automated routines. When you lot use this tool, you can automate tasks to launch applications, run specific commands, or execute scripts at a specific schedule or when a condition is met.
While the Task Scheduler app offers the about convenient environment to manage tasks on Windows 10, you can also use PowerShell to schedule, modify, and delete tasks, which can come in handy when you demand to streamlined the process of creating tasks on several devices or when you need to create a PowerShell script that needs to interact with the console.
In this Windows 10 guide, we will walk you through the basic steps to get started managing scheduled tasks using PowerShell commands.
- How to create scheduled task using PowerShell
- How to modify scheduled chore using PowerShell
- How to delete scheduled task using PowerShell
How to create a scheduled task using PowerShell
To create a scheduled chore with PowerShell on Windows 10, use these steps:
- Open up Kickoff.
- Search for PowerShell, right-click the top result, and select the Run equally administrator option.
-
Blazon the following command to create a variable to store the activity of the task and press Enter:
$activity = New-ScheduledTaskAction -Execute 'Program'In the command, make sure to replace 'Program' with the name of the programme you lot want to start. The "$activity" is a variable, and it does not thing the proper noun equally long as you continue it short, simple, and descriptive.
For example, this control tells Chore Scheduler to start the Notepad app:
$action = New-ScheduledTaskAction -Execute 'notepad.exe'
Source: Windows Central Quick tip: If you are trying to schedule a Command Prompt or PowerShell script, you lot volition employ the proper noun of the program for the "-Execute" option and "-Argument" option to specify the path of the script. For example,
$action = New-ScheduledTaskAction -Execute 'cmd.exe' -Argument C:\scripts\myscript.bat -
Blazon the following command to create a variable that stores the schedule information for the chore and press Enter:
$trigger = New-ScheduledTaskTrigger -SETTING -At TimeIn the command, brand certain to supersede SETTING and TIME with the details on when you lot desire to run the task. The $trigger is a variable, and it does not thing the name.
For example, this example tells Task Scheduler to run the task daily at eleven am:
$trigger = New-ScheduledTaskTrigger -Daily -At 11amQuick notation: For "SETTING," you tin can use -Once, -Daily, -Weekly, or -Monthly. And for the time, you tin use the 12 or 24-hour format. If you are using the "Weekly" selection, then yous also provide the "-DaysInterval" or "-DaysOfWeek" data followed past the corresponding information. For example, with "-DaysOfWeek," you lot can use Lord's day, Monday, Tuesday, Wed, Thursday, Friday, or Saturday (case:
-DaysOfWeek Monto run the chore every Monday), and "-DaysInterval," you lot volition provide the interval as number (example:-DaysInterval iito run the task every two days). -
Type the post-obit command to create the scheduled task using the variables you lot specified on the previous steps and printing Enter:
Register-ScheduledTask -Activity $action -Trigger $trigger -TaskPath "TASK-Folder" -TaskName "Chore-Proper name" -Clarification "OPTIONAL-DESCRIPTION-TEXT"In the command, make sure to update "TASK-NAME" with the job's actual proper name and "OPTIONAL-Clarification-TEXT" with the description of the task. The folder "-TaskPath" pick is not a requirement, but it will help keep tasks separate. If you do not specify the option with a path, the chore will be created inside the Task Scheduler Library folder.
For example, this command creates every bit a scheduled job with the "testTask" name, custom clarification, and with settings specified on steps No. 3 and 4:
Annals-ScheduledTask -Activity $activeness -Trigger $trigger -TaskPath "MyTasks" -TaskName "testTask" -Clarification "This task opens the Notepad editor"
Source: Windows Key
Once you lot consummate the steps, the task volition be created and scheduled according to your configuration.
How to change scheduled task using PowerShell
To modify an already scheduled task with PowerShell commands, utilize these steps:
- Open Start.
- Search for PowerShell, correct-click the tiptop result, and select the Run every bit ambassador option.
-
Type the post-obit command to create a variable to shop the schedule changes and press Enter:
$trigger = New-ScheduledTaskTrigger -SETTING -At Fourth dimensionIn the command, make certain to replace SETTING and Time with the new the updated information on when to run the task.
For example, this command updates the task with a new trigger schedule:
$trigger = New-ScheduledTaskTrigger -Weekly -DaysOfWeek Monday -At 2pm -
(Optional) Type the following command to create a variable to store the new action changes and press Enter:
$action = New-ScheduledTaskAction -Execute 'PROGRAMIn the command, brand sure to replace 'PROGRAM' with the proper name of the new programme you want to start.
For example, this command tells the Task Scheduler to change the start program to WordPad:
$action = New-ScheduledTaskAction -Execute 'C:\Program Files\Windows NT\Accessories\wordpad.exe'
Source: Windows Key -
Blazon the following command to change the settings of the scheduled job and press Enter:
Set-ScheduledTask -Trigger $trigger -Action $action -TaskPath "TASK-Binder" -TaskName "Task-NAME"In the control, replace TASK-Proper name with the name of the task you want to update. If y'all are storing the task in a specific folder, make sure to update TASK-Binder with the name of the folder storing the chore. Otherwise, remove the -TaskPath "Chore-Binder" option from the command.
For example, this command updates the testTask task with the new action and trigger settings:
Gear up-ScheduledTask -Trigger $trigger -Action $action -TaskPath "MyTasks" -TaskName "testTask"
Source: Windows Central
The higher up example shows the steps to update the "triggers" and "actions" settings, but you lot tin can also update but one, three, or more than settings. You only need to create the variable and then utilize it with the Set up-ScheduledTask command. For case, using the above steps every bit a reference, you could skip step No. 4, and and then use this command to only update the schedule: Set up-ScheduledTask -Trigger $trigger -TaskName "testTask".
How to delete scheduled job using PowerShell
To delete a scheduled task from the Task Scheduler with PowerShell, use these steps:
- Open Start.
- Search for PowerShell, correct-click the superlative result, and select the Run every bit administrator option.
-
(Optional) Type the following command to confirm the task exists and press Enter:
Get-ScheduledTask -TaskName "TAKS-NAME"In the control, make sure to supplant "TAKS-Name" with the name of the task.
For instance, this command shows the testTask task:
Get-ScheduledTask -TaskName "testTask" -
Type the following command to delete the scheduled job and press Enter:
Unregister-ScheduledTask -TaskName "TASK-NAME" -Ostend:$imitationIn the command, brand sure to supersede "TAKS-NAME" with the proper name of the task. The "-Ostend:$false" option deletes the chore without asking for confirmation.
For example, this control deletes the testTask task:
Unregister-ScheduledTask -TaskName "testTask" -Confirm:$false
Source: Windows Central -
(Optional) Type the post-obit command to ostend the job has been deleted and press Enter:
Get-ScheduledTask -TaskName "TAKS-Proper noun"In the command, make certain to replace "TAKS-NAME" with the name of the task.
For example, this control to confirm the testTask task is no longer available:
Go-ScheduledTask -TaskName "testTask"
Once you complete the steps, if you receive an error indicating no chore with that specific name, information technology means that the task has been deleted.
This guide focuses on the bones steps to start managing scheduled tasks using PowerShell. However, using PowerShell commands, y'all can manage many other settings. You lot can start and stop tasks, view job data, and much more using the many available modules.
In addition to using PowerShell, you tin also create, modify, and remove tasks using Command Prompt.
More Windows 10 resources
For more helpful articles, coverage, and answers to common questions about Windows ten, visit the following resources:
- Windows ten on Windows Cardinal – All you need to know
- Windows x assistance, tips, and tricks
- Windows 10 forums on Windows Central
Nosotros may earn a commission for purchases using our links. Larn more.
Source: https://www.windowscentral.com/how-create-scheduled-tasks-powershell-windows-10
Posted by: wolferemplume.blogspot.com

0 Response to "How to create scheduled tasks with PowerShell on Windows 10"
Post a Comment