Language: PowerShell

View on GitHub to download or comment.

See the Client API Examples Introduction for additional information and prerequisites.

Samples index

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

adt-search.ps1
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 "**********"
	}
}

Comments

View on GitHub to comment.