PowerShell script exchange
Post Reply
pjbryant
Novice
Posts: 9
Liked: never
Joined: Nov 05, 2012 10:58 am
Full Name: P J Bryant
Contact:

set-VBRjoboptions

Post by pjbryant »

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.
tsightler
VP, Product Management
Posts: 6013
Liked: 2843 times
Joined: Jun 05, 2009 12:57 pm
Full Name: Tom Sightler
Contact:

Re: set-VBRjoboptions

Post by tsightler »

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)
}
Post Reply

Who is online

Users browsing this forum: No registered users and 18 guests