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 $vm.name
        $jobOptions | Add-Member -MemberType NoteProperty -Name "JobName" -value $job.name

        $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

}
SRedlin
Novice
 
Posts: 8
Liked: never
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 {$_.id -eq $Childjob.Info.ParentScheduleId} | select name

Thanks.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin


Return to PowerShell



Who is online

Users browsing this forum: No registered users and 6 guests