HOWTO: Delete scheduled task with PowerShell

This is a much more flexible code, Unlike Unregister-ScheduledJob cmdlet , which allows you to access only jobs in a folder: Task Scheduler Library\Microsoft\Windows\PowerShell\ScheduledJobs. That script allows you to delete a task from any folder in Windows Task Scheduler.

1. Start Windows PowerShell

Click Start, type PowerShell, and then click Windows PowerShell

2. Use This Cmdlet to Delete Scheduled Task

# create Task Scheduler COM object
$TS = New-Object -ComObject Schedule.Service
# connect to local task sceduler
$TS.Connect($env:COMPUTERNAME)
# get tasks folder (in this case, the root of Task Scheduler Library)
$TaskFolder = $TS.GetFolder("\")
# get tasks in folder
$Tasks = $TaskFolder.GetTasks(1)
# define name of task to delete
$TaskToDelete = "MyTask"
# step through all tasks in the folder
foreach($Task in $Tasks){
if($Task.Name -eq $TaskToDelete){
Write-Host ("Task "+$Task.Name+" will be removed")
$TaskFolder.DeleteTask($Task.Name,0)
}
}

Also consider using Action1 to delete scheduled task if:

  • - You need to perform this action on multiple (hundreds or even thousands) computers simultaneously.
  • - Some of your endpoints are laptops not connected to corporate network at all times.

Action1 is a cloud-based platform for software deployment, software/hardware inventory, patch management, endpoint configuration and more. It is free with basic functionality.


Other Relevant HOWTOs: