Hello,
The below script can be used to find scheduled tasks whose names start with a certain string and output the task names. In the script, the $searchString variable specifies the string for search. The script can be executed in Windows PowerShell on the computer where the Adaxes service runs.
[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi")
$searchString = "My Task ID" # TODO: modify me
# Get the scheduled task container parh
$ns = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$service = $ns.GetServiceDirectly("localhost")
# Build criteria
$criteria = New-AdmCriteria -Type "adm-ScheduledTask" -Expression {name -startswith $searchString}
# Search options
$scheduledTasksContainerPath = $service.Backend.GetConfigurationContainerPath("ScheduledTasks")
$searcher = $service.OpenObject($scheduledTasksContainerPath, $NULL, $NULL, 0)
$searcher.SearchScope = "ADS_SCOPE_SUBTREE"
$searcher.Criteria = $criteria
try
{
# Execute search
$searchResultIterator = $searcher.ExecuteSearch()
$searchResults = $searchResultIterator.FetchAll()
}
finally
{
# Release resources
if ($searchResultIterator) { $searchResultIterator.Dispose() }
}
if ($searchResults.Length -eq 0)
{
# No tasks found
Write-Host "No tasks were found"
return
}
foreach ($searchResult in $searchResults)
{
# Bind to the task
$task = $service.OpenObject($searchResult.AdsPath, $NULL, $NULL, 0)
# Get task name
$taskName = $task.Get("name")
# Output task name
Write-Host $taskName
}
To get a schedule of a task, the GetRecurrencePattern method of the IAdmScheduledTask interface can be used. For more details on how to manage scheduled tasks, have a look at the following SDK article: https://www.adaxes.com/sdk/ManagingScheduledTasks.