PowerShell script exchange
Post Reply
tom_nl
Enthusiast
Posts: 29
Liked: 4 times
Joined: Nov 02, 2018 9:13 am
Contact:

Configure retries on job

Post by tom_nl »

Hi,

I can't find the cmdlet to configure the number of retries and wait time for a job.
Please help :)

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

Re: Configure retries on job

Post by veremin » 1 person likes this post

Try this example:

Code: Select all

Asnp VeeamPSSnapin
$Job = Get-VBRJob -name "Name of your job"
$ScheduleOptions = $Job.GetScheduleOptions()
$ScheduleOptions.Retrytimes = "Number of retries"
$ScheduleOptions.Retrytimeout = "Timeout in minutes"
Set-VBRJobScheduleOptions -Job $Job -Options $ScheduleOptions
Thanks!

JustinP
Novice
Posts: 5
Liked: 1 time
Joined: Apr 16, 2020 6:02 pm
Full Name: Justin Pauls
Contact:

Re: Configure retries on job

Post by JustinP »

This just became useful for me.

dozens of daily jobs, I want to increase and not have to wizard this.

It'd be so nice if we could display / modify job values in a table view inside Veeam BRC directly...

JustinP
Novice
Posts: 5
Liked: 1 time
Joined: Apr 16, 2020 6:02 pm
Full Name: Justin Pauls
Contact:

Re: Configure retries on job

Post by JustinP »

So I've tried to run a version of that PS script, however I get an error (I'm old hat at KSH / Bash scripts, batch however I'm new to PS).

I've added the snapin, pulled the jobs and can even output the field value I want to change.

When I try and update the $ScheduleOptions.RetryTimes, I get the following error:

Code: Select all

> echo $ScheduleOptions |select Retrytimes
RetryTimes
----------
3
1
3
1
3
1
3
1
1
1
3
1
1
3
3

Code: Select all

> $ScheduleOptions.RetryTimes = "2"
The property 'RetryTimes' cannot be found on this object. Verify that the property exists and can be set.
At line:1 char:1
+ $ScheduleOptions.RetryTimes = "2"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : PropertyAssignmentException
I'm sure it's probably me, or my syntax.

soncscy
Expert
Posts: 258
Liked: 109 times
Joined: Aug 04, 2019 2:57 pm
Full Name: Harvey Carel
Contact:

Re: Configure retries on job

Post by soncscy »

Hi Justin,

What was fed into $ScheduleOptions?

You should be able to do something like:

$Job = Get-VBRJob -name 'your job'
$Job.ScheduleOptions.RetryTimes = "1"
$Job.Update()

I have a guess that you maybe just saved some data from somewhere into $ScheduleOptions and you don't have a CBackupJob object there.

For your first output, you've got all your Jobs in there? $ScheduleOptions is an array from Get-VBRJob?

If that's the case, loop over the array and set each one one by one.

Or, you have to call items from the array with $ScheduleOptions[N] where N is the item from the array you want.

If you're trying to set this for all of your jobs, this is pretty simple to loop over, but you're getting the error because what PS is gonna do when you call the property on the Array is just process each item in the array and print the property to the terminal. But you can't apply the change to the object itself.

PS C:\Users\Administrator\Desktop> $job.GetType()

IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True False CBackupJob System.Object


PS C:\Users\Administrator\Desktop> $jobs.GetType()

IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True Object[] System.Array
$jobs is all my jobs, and $job is a single job.

That's why, as I understand it, you're getting this.

So, instead to set it for all those jobs, do:

Code: Select all

foreach($Job in $ScheduleOptions){
     $Job.ScheduleOptions.RetryTimes = "1"
     $Job.Update()
}

oleg.feoktistov
Veeam Software
Posts: 664
Liked: 236 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Configure retries on job

Post by oleg.feoktistov »

Hi Justin,

What Harvey elaborated on is the most likely scenario here. Please let us know, though, if you have any further questions.

Thanks,
Oleg

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests