Scripting Changes to Jobs

Follow

One of the benefits that JAMS provides is the power to script the creation of new jobs, setups, folders, or any JAMS definitions.  Because the JAMS Module includes a PowerShell provider, you can use native PowerShell commands like New-Item or Get-Item to create or change JAMS definitions.

For Example, to create a new Job:

  

Import-Module JAMS

New-PSDrive JD JAMS localhost 

$job = New-Item JD:\Samples\Jobs\MyJob -itemtype Job
$job.Description = "This job was added programmatically"
$job.ScheduledDate = "Monday, Tuesday, Wednesday, Thursday"
$job.ScheduledTime = [MVPSI.JAMS.TimeOfDay] "23:40"
$job.AutoSubmit = $false
$job.Source = "Dir C:\"
$job.SubmitMethodName = "Command"
$requires = new-object MVPSI.JAMS.ResReq("Widgets", 12)
$job.Requirements.Add($requires)
$requires = new-object MVPSI.JAMS.ResReq("Gadgets", 5)
$job.Requirements.Add($requires)
$job.Update() 

  

or to change an existing Job:

  

Import-Module JAMS

New-PSDrive JD JAMS localhost

$job = Get-Item JD:\Samples\Jobs\MyJob
$job.Description = "This job was changed programmatically"
$job.ScheduledDate = "Monday, Tuesday, Wednesday, Thursday"
$job.ScheduledTime = [MVPSI.JAMS.TimeOfDay] "21:40"
$job.AutoSubmit = $false
$job.Source = "Dir C:\Temp"
$job.SubmitMethodName = "Command"
$requires = new-object MVPSI.JAMS.ResReq("Widgets", 7)
$job.Requirements.Add($requires)
$requires = new-object MVPSI.JAMS.ResReq("Gadgets", 2)
$job.Requirements.Add($requires)
$job.Update()

  

 

Have more questions? Submit a request

Comments