This PowerShell script uses the adTempus API to hold or release a specified job or group.
Created
March 2, 2021 18:11
-
-
Save arcanadev/5290284bf327598724569dc77bd366a9 to your computer and use it in GitHub Desktop.
Hold or release a job or group #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 = ".", | |
[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() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment