set-VBRjoboptions

PowerShell script exchange

set-VBRjoboptions

Veeam Logoby pjbryant » Sun Dec 09, 2012 6:04 pm

I'm in the middle of fixing up a script to fully chase the vCentre around the cluster and back it up (the not quite supported "edit the SQL database" version does work - but I'm trying to find a method using supported tools). I will publish it here when done. Although the job works, I have one last problem...

The method I am using is to remove the VM from the job, and then add it back in, however on doing so 1 option that is set on the job gets reset and Set-VBRJobOptions does not appear to play ball.

The relevant part of the script does this:
#get the job options
$Options = Get-VBRJobOptions $Job
#and force the transaction log trunction to be never (as preferred)
$Job.vssoptions.TransactionLogsTruncation = "Never"
Set-VBRJobOptions -job $Job -options $Options

The logic is
* get the options for the job as it has been created.
* make any required changes to the job options
* then modify with (in this case) one of the permitted values ("Never, OnlyOnSuccessJob, Always")
* write it back,

The script works without error (and changing away from an allowed value for the Truncation does generate an error - so I know the code is OK), but the backup job in VBR remains unchanged. Any idea what have I done wrong? Or is this a bug in the cmdlet?

Any suggestions gratefully received.
pjbryant
Novice
 
Posts: 9
Liked: never
Joined: Mon Nov 05, 2012 10:58 am
Full Name: P J Bryant

Re: set-VBRjoboptions

Veeam Logoby tsightler » Sun Dec 09, 2012 7:30 pm

I think the problem is that the VSS options you are attempting to set are object level settings, not job level, so you have to loop through the objects in the job to set these parameters, just like in the GUI. I believe that something like the below should work:

Code: Select all
$JobObjects = Get-VBRJobObject -job $Job
foreach ($object in $JobObjects){
    $VSSJobObjectOptions = $object.GetVssOptions()
    $VSSJobObjectOptions.TransactionLogsTruncation = "Never"
    $object.SetVssOptions($VSSJobObjectOptions)
}
tsightler
Veeam Software
 
Posts: 4768
Liked: 1737 times
Joined: Fri Jun 05, 2009 12:57 pm
Full Name: Tom Sightler


Return to PowerShell



Who is online

Users browsing this forum: No registered users and 8 guests