This job will read a listing of agents from a text file, and submit a job in the list to each agent. This job also checks the status of each job it submitted, and writes them out to its own log file.
Import-Module JAMS # # Read a file which contains a list of Agents. The agents list contains a list with each agent name on on each line of the text file. # $agentList = Get-Content C:\Temp\AgentList.txt # # Initialize an array to hold all of the jobs that we are about to submit # $processEntries = @() # # Submit a job for each of the things in the file # foreach($agent in $agentList) { # # Submit Each job using Submit-JAMSEntry to each agent in the list. We submit the SleepJob job for each agent in the list that we found, replace SleepJob with the path to the job you want to submit for each agent. # $submitResult = Submit-JAMSEntry \SleepJob -Agent $agent -Verbose # # Add the JAMSEntry number to the array # $processEntries += $submitResult.JAMSEntry } # # Wait for all of the jobs we submitted to complete # Wait-JAMSEntry $processEntries -verbose # # Now, check the status of each entry # foreach($entry in $processEntries) { $entryInfo = Get-JAMSEntry -Entry $entry write-host "Final status of entry " $entryInfo.JAMSEntry "is" $entryInfo.FinalStatus }
Comments