This PowerShell script searches all adTempus jobs for a specified string.
Created
March 2, 2021 19:37
-
-
Save arcanadev/2b4dbaa3e898f648d7f792dfbb55d8ae to your computer and use it in GitHub Desktop.
Search for text in jobs #adtempus #api #powershell #version4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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