Skip to content

Executing Scheduled Tasks

The following code sample executes the Run Now command for 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)

# Run the Scheduled Task
$myScheduledTask.RunNow()

See also