PowerShell script exchange
Post Reply
icshoward
Lurker
Posts: 1
Liked: never
Joined: Nov 09, 2012 7:04 am
Full Name: Howard Lee
Contact:

VBR6.5 - Schedule "After this job"

Post by icshoward »

Hi,
You may see there is a new feature about chain execution of jobs in version 6.5. Is there a syntax or command that can modify the option field using powershell?
Thanks.
Vitaliy S.
VP, Product Management
Posts: 27055
Liked: 2710 times
Joined: Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov
Contact:

Re: VBR6.5 - Schedule "After this job"

Post by Vitaliy S. »

Hi Howard,

Unfortunately, there is no such command in PowerShell. However, you may want to use the following cmdlet to check current job status and based on the returned result trigger the subsequent backup jobs.

Thanks!
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: VBR6.5 - Schedule "After this job"

Post by veremin » 2 people like this post

Although, what Vitaliy said was absolutely true, I can propose you some kind of workaround which is able to bypass existing VB&R PowerShell limitations.
What I’m going to represent is:

1)Creation of .bat-file, which consists of PowerShell-commands and which is responsible for starting second, third, whatever number of job in the chain.
2)Specifying this file as a target for Job’s post activity.

I'll show you PowerShell script regarding case of chain execution of only two jobs. However, by the means of simply modifications you can reach whatever scale you want.

First of all, you have to decide where you’re going to store you .bat –file. Say, it’d be D:\Test.bat.
With this knowledge modify Post-activity settings of your first job:

Code: Select all

asnp VeeamPSSnapin
 
$Job = Get-VBRJob | ?{$_.Name –eq “Name of the first job”}
$jo = $job.GetOptions()
$jo.PostJobCommand.Enabled = $True
$jo.PostJobCommand.Commandline = "D:\Test.bat"
$job.SetOptions($jo) 
Then write simple PowerShell-script responsible for execution second job in chain:

Code: Select all

asnp VeeamPSSnapin;
$job = Get-VbrJob -name "Name of the second job";
Start-VbrJob -job $job;
Translate it to .bat appropriate format. So, you .bat file should look like this:

Code: Select all

powershell -Command "& {asnp VeeamPSSnapin;$job = Get-VbrJob -name "Name of the second job";Start-VbrJob -job $job;}"
That’s all.

Hope this helps.
Thanks.
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: VBR6.5 - Schedule "After this job"

Post by veremin »

Just want to update the community with the latest information regarding linking jobs through the PowerShell. We’ve fixed previously existing bug with “SetScheduleDependentJobs” method. So, if you’re willing to set a dependent job kindly use the following script:

Code: Select all

Asnp VeeamPSSnapin
$Job1 = Get-VBRJob -name "Name of first job"
$Job2 = Get-VBRJob -name "Name of second job"
$Job2.SetScheduleDependentJobs($Job1)
Set-VBRJobSchedule -Job $Job1 -AfterJob $Job2  
As the result, backup job 2 will be scheduled after Backup Job 1.
Hope this helps.
Thanks.
ghalluin
Lurker
Posts: 1
Liked: never
Joined: Aug 12, 2014 7:33 am
Contact:

Re: VBR6.5 - Schedule "After this job"

Post by ghalluin »

Hi

Is the cmdlet SetVbrJobSchedule available in Veeam 6.5.0.109 x64 ?

Because I have an error : cmdlet SetVbrJobSchedule not recognized.
I have already added the snappin Veeam and other cmdlet work properly...

Thanks
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: VBR6.5 - Schedule "After this job"

Post by veremin »

If my memory serves me well, back at v6.5 days, it was impossible to set dependent job, using PS snap-in, and the only workaround was to use .bat-command. Anyway, you can open a VB&R PS snap-in (Menu -> PowerShell), type Get-VBRCommand and see whether or not the said commandlet is present. Thanks.
nefes
Veeam Software
Posts: 643
Liked: 162 times
Joined: Dec 10, 2012 8:44 am
Full Name: Nikita Efes
Contact:

Re: VBR6.5 - Schedule "After this job"

Post by nefes »

Set-VBRJobSchedule was introduced in 7.0
There were Set-VBRJobScheduleOptions in 6.5
You can also check this page to the list of available cmdlets: http://helpcenter.veeam.com/backup/70/powershell/
All cmdlets have an information, were they appear in 7.0 or came from previous versions.
Post Reply

Who is online

Users browsing this forum: No registered users and 17 guests