Run After Job

PowerShell script exchange

Run After Job

Veeam Logoby SRedlin » Tue May 02, 2017 2:15 pm

Hey Folks,

In my code i loop thru all jobs and all vmnames and want to add the information when the job is scheduled after a specific job?
How can i archive this goal? :)

Code: Select all
$jobs = Get-VBRJob | ?{$_.JobType -eq "Backup"}
foreach ($job in $jobs) {
    foreach ($vm in $job.GetObjectsInJob()) {
        $jobOptions = New-Object PSObject
        $jobOptions | Add-Member -MemberType NoteProperty -Name "VMName" -value $
        $jobOptions | Add-Member -MemberType NoteProperty -Name "JobName" -value $

        $Schedule = $Null
        $Schedule = Get-VBRJobScheduleOptions -Job $job

        if($test.ScheduleOptions.OptionsScheduleAfterJob.IsEnabled -eq $True){

        $jobOptions | Add-Member -MemberType NoteProperty -Name "Run After" -Value "Run After" -ErrorAction SilentlyContinue

Posts: 10
Liked: 1 time
Joined: Fri Sep 23, 2016 10:20 am
Full Name: Stefan Redlin

Re: Run After Job

Veeam Logoby v.Eremin » Tue May 02, 2017 3:00 pm 1 person likes this post

You can find a name of parent job, using the following script:

Code: Select all
ASnp VeeamPSSNapin
$Childjob = Get-VBRJob -name "Name of child job"
Get-VBRJob | where {$ -eq $Childjob.Info.ParentScheduleId} | select name

Veeam Software
Posts: 14722
Liked: 1103 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Return to PowerShell

Who is online

Users browsing this forum: Bing [Bot] and 23 guests