Powershell Script to turn off job

Ken T (33 posts)
August 5, 2019 04:18 PM
Accepted Answer

Does anyone have a Powershell script that will allow me to disable an adTempus job? I'd like to able to run the script to turn off and on an adTempus job from the command line.

 

 

This topic has an accepted answer. Jump to it.
Bill Staff (599 posts)
August 6, 2019 11:43 AM
Accepted Answer

You can use the attached script file or this code:

param (
    [string]$server = ".",
    [string]$job,
    [switch]$release=$False,
    [switch]$hold=$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()

$jobs=$context.GetJobs($job) | ForEach-Object {
    if($release){
        $_.UpdateHoldType($_.HoldType -band (-bnot [ArcanaDevelopment.adTempus.Shared.HoldType]::DisableTriggers), [ArcanaDevelopment.adTempus.Shared.MissedJobCheckOptions]::NoCheck)
        Write-Host "Released ""$($_.FullyQualifiedName)"""
    }
    elseif($hold){
        $_.UpdateHoldType([ArcanaDevelopment.adTempus.Shared.HoldType]::DisableTriggers, [ArcanaDevelopment.adTempus.Shared.MissedJobCheckOptions]::NoCheck)
        Write-Host "Held ""$($_.FullyQualifiedName)"""
    }
    else{
        Write-Host """$($_.FullyQualifiedName)"": $($_.HoldType)"
    }
}

$context.Dispose()
$adTempus.Dispose()

Use the "-job" parameter to specify the job name to process. This accepts wildcards and group paths. For example,

-job "group 1\*"

will operate on all jobs in "group 1".

Use the optional "-server" parameter to connect to a different server.

Use the "-hold" switch to hold jobs, "-release" to release them. If you don't use either, it will show you the current hold state.

Note that this script only alters the "Disable Triggers" hold option. Other execution types are not affected (e.g., manual execution is still allowed). If you want different behavior, change the script to use the appropriate HoldType values.

 

Attachments

Ken T (33 posts)
November 23, 2019 12:33 PM
Accepted Answer

Thanks Bill!

 

How would I reference to instances, in the case where I have different adTempus instances setup on the same server. I'd like to refer to a specific instance.

 

Bill Staff (599 posts)
November 25, 2019 01:21 PM
Accepted Answer
Use the -server parameter with the syntax "computername\instancename". For the local server, use ".\instancename".

Replies are disabled for this topic.