Script for chaining jobs in BE 2012
This BEMCLI script is a follow-up to my article
https://www-secure.symantec.com/connect/articles/use-bemcli-chain-jobs
This script makes it easier to set up the jobs that you want to run in sequence.
1) Get the list of jobs
You can get the list of jobs that you want to run by running this cmdlet and pipe it to a text file
Get-BEJob | select-object name > jobs.txt
If you want to get only a certain type of job, you can use the parameters of the Get-BEJob cmdlet to do so. For example,
Get-BEJob -Jobtype Duplicate
will get you all the duplicate jobs
and
Get-BEJob -Status Missed
will get you the list of of missed jobs.
2) Arrange the job in sequence
Edit the text file with the job names and arrange the jobs in the sequence that you want to run them. The content of the text file should look something like this
Server-1 Backup 00021-BackupServer-3 Backup 00014-BackupServer-1 Backup 00003-BackupServer-2 Backup 00008-BackupServer-1 Backup 00006-Backup
3) Execute the script from the command line or as a pre-/post-command of a job.
Chain-BEJobs "\jobs.txt" "\results.htm"
The first parameter is a file containing the list of jos and the second optional parameter is the file which will contain the results of the jobs. If the second parameter is omitted, then no result will be output. You can supply the full path for both files.
To prepare your environment to run BEMCLI, you might want to read my article
https://www-secure.symantec.com/connect/articles/preparing-your-powershell-environment-run-bemcli-and-scripts