Skip to content

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
$admNS = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$admService = $admNS.GetServiceDirectly("localhost")

# Bind to the 'Scheduled Tasks' container
$scheduledTasksPath = $admService.Backend.GetConfigurationContainerPath(
    "ScheduledTasks")
$scheduledTasksContainer = $admService.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
$admNS = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$admService = $admNS.GetServiceDirectly("localhost")

# Bind to the 'My Container' container
$scheduledTasksPath = $admService.Backend.GetConfigurationContainerPath(
    "ScheduledTasks")
$scheduledTasksPathObj = New-Object "Softerra.Adaxes.Adsi.AdsPath"`
    $scheduledTasksPath
$myContainerPath = $scheduledTasksPathObj.CreateChildPath("CN=My Container")
$myContainer = $admService.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