Creating scheduled task containers
The following code sample creates a container for scheduled tasks.
[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 Tasks' container
$scheduledTasksPath = $service.Backend.GetConfigurationContainerPath(
"ScheduledTasks")
$scheduledTasksContainer = $service.OpenObject($scheduledTasksPath,
$null, $null, 0)
# Create container
$myContainer = $scheduledTasksContainer.Create("container","CN=My Container")
$myContainer.SetInfo()
The following code sample creates a scheduled task in a specific container.
[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 'My Container' container
$scheduledTasksPath = $service.Backend.GetConfigurationContainerPath(
"ScheduledTasks")
$scheduledTasksPathObj = New-Object "Softerra.Adaxes.Adsi.AdsPath"`
$scheduledTasksPath
$myContainerPath = $scheduledTasksPathObj.CreateChildPath("CN=My Container")
$myContainer = $service.OpenObject($myContainerPath,
$null, $null, 0)
# Create a scheduled task
$task = $myContainer.Create("adm-ScheduledTask", "CN=My Task")
$task.ObjectType = "user"
$task.Description = "My description"
$task.Disabled = $false
$task.ExecutionMoment = "ADM_BUSINESSRULEEXECMOMENT_BEFORE"
$task.OperationType = "none"
$recurrencePattern = $task.GetRecurrencePattern()
$recurrencePattern.RecurrenceType = "ADM_RECURRENCEPATTERNTYPE_ONCE"
$recurrencePattern.PatternStartDateTime = (Get-Date).AddDays(30)
$task.SetRecurrencePattern($recurrencePattern)
$task.SetInfo()
See also
- Managing scheduled tasks
- Binding to Adaxes-specific objects
- Managing Adaxes-specific objects
- IADs
- IADsContainer
- IAdmScheduledTask
- Online script repository