Skip to content

Instantly share code, notes, and snippets.

@arcanadev
Created March 2, 2021 19:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arcanadev/2b4dbaa3e898f648d7f792dfbb55d8ae to your computer and use it in GitHub Desktop.
Save arcanadev/2b4dbaa3e898f648d7f792dfbb55d8ae to your computer and use it in GitHub Desktop.
Search for text in jobs #adtempus #api #powershell #version4

This PowerShell script searches all adTempus jobs for a specified string.

param (
[string]$server = ".",
[string]$find = $(throw "-find is required."),
[switch]$details = $false
)
add-type -path "c:\program files\arcana development\adtempus\4.0\ArcanaDevelopment.adTempus.Client.dll"
$adtempus=[ArcanaDevelopment.adTempus.Client.Scheduler]::Connect($server,[ArcanaDevelopment.adTempus.Shared.LoginAuthenticationType]::Windows,"","")
$context=$adtempus.NewDataContext()
$options=new-object ArcanaDevelopment.adTempus.Shared.ObjectSearchOptions
$options.Action=[ArcanaDevelopment.adTempus.Shared.SearchReplaceType]::SearchOnly
$options.ReturnObjects=$true
$options.IncludeObjects.Add([ArcanaDevelopment.adTempus.Shared.WellKnownOIDs]::RootGroup) #Search the root job group and all its contents
$options.SearchSubGroups=$true #including sub-groups
$options.TextToFind=$find #look for the specified text
$results=$null #this will hold the results
$messages=$null #this would hold error messages if we were doing a replace
$context.SearchAndReplace($options,[ref] $results,[ref] $messages)
foreach($result in $results)
{
write-host ("Job " + $result.GetPrimaryObject().FullyQualifiedName)
if($details)
{
foreach($match in $results.Matches)
{
#write-host ($match.FindLocation + " > " + $match.FieldDisplayName)
}
write-host "**********"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment