Skip to content

Enabling and disabling Scheduled Tasks

The following code sample shows how to enable and disable a Scheduled Task.

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

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

# Bind to 'My Task' Scheduled Task
$scheduledTasksPath = $admService.Backend.GetConfigurationContainerPath(
    "ScheduledTasks")
$scheduledTasksPathObj = New-Object "Softerra.Adaxes.Adsi.AdsPath" `
    $scheduledTasksPath
$myScheduledTaskAdsPath = $scheduledTasksPathObj.CreateChildPath( `
    "CN=My Task")
$myScheduledTask = $admService.OpenObject($myScheduledTaskAdsPath, $NULL, $NULL, 0)

# Enable the Scheduled Task
$myScheduledTask.Disabled = $False
$myScheduledTask.SetInfo()

# Disable the Scheduled Task
$myScheduledTask.Disabled = $True
$myScheduledTask.SetInfo()

See also