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
$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)
# Run the scheduled task
$myScheduledTask.RunNow()
See also
- Managing scheduled tasks
- Binding to Adaxes-specific objects
- Managing Adaxes-specific objects
- IAdmScheduledTask
- Online script repository