Deleting All Scheduled Tasks using the Schedule.Service Com Object

I wrote up a pretty cool advanced function that will delete individual scheduled tasks, but what if someone wants to just delete all scheduled tasks within a parent folder rather than have to name each one? For instance, here is a script I found online that deletes individual tasks:

# create Task Scheduler COM object
$TS = New-Object -ComObject Schedule.Service
# connect to local task sceduler
# 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")

So how would we tell the DeletTask method to just delete all of the tasks within a task folder rather than having to define each one? Is there a wild card (i.e. the asterisk *) I can use that I am not aware of?


Try :-

for exact

Get-ScheduledTask | Where TaskPath -eq 'PutYourFolderPathHere' | Unregister-ScheduledTask -Confirm:$false

for wildcards

Get-ScheduledTask | Where TaskPath -like 'ParentFolderPath*' | Unregister-ScheduledTask -Confirm:$false

I am using the Schedule Service com object, not the Scheduled Tasks cmdlets. I am running this on Win 7 systems and the Scheduled Tasks cmdlets are available only on Win 8.1 and Server 2012 R2, from what I understand.

Disregard, I figured out how to do it. Thanks anyway man