Deleting scheduled tasks

The following code sample deletes a scheduled task.

[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi")

# Connect to the Adaxes service
$ns = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$service = $ns.GetServiceDirectly("localhost")

# Bind to the scheduled task
$scheduledTasksPath = $service.Backend.GetConfigurationContainerPath("ScheduledTasks")
$scheduledTasksPathObj = New-Object "Softerra.Adaxes.Adsi.AdsPath" $scheduledTasksPath
$myScheduledTaskAdsPath = $scheduledTasksPathObj.CreateChildPath("CN=My Task")

$myScheduledTask = $service.OpenObject($myScheduledTaskAdsPath, $null, $null, 0)

# Delete the task
$myScheduledTask.DeleteObject("ADM_DELETEOBJECTFLAGS_AUTO")

See also