Skip to content

Instantly share code, notes, and snippets.

@arcanadev
Last active February 11, 2021 16:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arcanadev/88f7ee4143cbb3198896666968698207 to your computer and use it in GitHub Desktop.
Save arcanadev/88f7ee4143cbb3198896666968698207 to your computer and use it in GitHub Desktop.
Find jobs not run in the last X days #adtempus #api #powershell #version4

This PowerShell script uses the adTempus API to find all jobs on an adTempus server that have not been run within the last x days, or that have never been run at all.

Use the -days parameter to specify x (default is 180).

Use -server to connect to an adTempus instance other than the local instance.

See this forum post for more information.

param (
[string]$server = ".",
[int]$days = 180
)
add-type -path "c:\program files\arcana development\adtempus\4.0\ArcanaDevelopment.adTempus.Client.dll"
$cutoffDate=[DateTime]::UtcNow.Subtract([TimeSpan]::FromDays($days))
$adtempus=[ArcanaDevelopment.adTempus.Client.Scheduler]::Connect($server,[ArcanaDevelopment.adTempus.Shared.LoginAuthenticationType]::Windows,"","")
$context=$adtempus.NewDataContext()
$restartPaging=$false
$context.GetJobs("*",[ArcanaDevelopment.adTempus.Shared.ObjectFetchOptions]::StubsOnly,0,[ref] $restartPaging) |
Select-Object Name,@{n="GroupName";e={if($_.Group.IsRootGroup) {""} else{$_.Group.FullyQualifiedName}}},@{n="LastStart";e={$_.JobStatus.ExecutionStart}},@{n="JobId";e={$_.OID.ObjectID}} |
Sort-Object -Property GroupName,Name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment