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 uses the adTempus API to hold or release a specified job or group.

adt-hold-release.ps1
param (
    [string]$server = ".",
	[ValidateSet('hold','release')]
    [string]$action = "",
	[string]$job = "",
	[string]$group = ""
 )
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()

if($job -ne "")
{
	$target=$context.GetJob($job)
}
elseif($group -ne "")
{
	if($group.Equals("\"))
	{
		$group=""
	}
	$target=$context.GetJobGroup($group)
}
else
{
    write-host ("Specify -job or -group")
}

if($target -ne $null)
{
	if($action.Equals("hold"))
	{
		$target.UpdateHoldType([ArcanaDevelopment.adTempus.Shared.HoldType]::DisableAll, [ArcanaDevelopment.adTempus.Shared.MissedJobCheckOptions]::NoCheck)
		write-host ("Held " + $target.ClassName + " " + $target.GetDescription())
	}
	elseif($action.Equals("release"))
	{
		$target.UpdateHoldType([ArcanaDevelopment.adTempus.Shared.HoldType]::NotHeld, [ArcanaDevelopment.adTempus.Shared.MissedJobCheckOptions]::NoCheck)
		write-host ("Released " + $target.ClassName + " " + $target.GetDescription())
	}
	else
	{
		write-host ("Invalid action")
	}
}
if($adTempus -ne $null)
{
	$adTempus.Dispose()
}

Comments

View on GitHub to comment.