PowerShell script exchange
Post Reply
tsightler
VP, Product Management
Posts: 6053
Liked: 2874 times
Joined: Jun 05, 2009 12:57 pm
Full Name: Tom Sightler
Contact:

VSS Options and Credentials for child objects

Post by tsightler » 6 people like this post

I wanted to post this here for future reference in case I or anyone else needs this in the future as it's come up several times over the years. There are already code examples for setting VSS options for the job, and for individual objects in the job, however, in some cases the job object is a parent contain object such as a folder, resource pool, or datastore, however, you may need to set specific VSS options or credentials on child objects of the contain. This is very easy with the GUI, but it's non-obvious how to accomplish this via Powershell. At first it didn't even seem possible but after a little playing around, it turned out to be quite easy, just find the object, add it to the job, then set it's type to a VSSChild and then set the VSS options for the object. Since the object type has been converted to a VssChild type it will no show up as explicitly included in the job, but will show up with explicit VSS options just like the GUI. Here's the code to do that:

Code: Select all

$job = Get-VBRJob -Name <Job_Name>
$vm = Get-VBRViEntity -Name <VM_Name>
Add-VBRViJobObject -Job $job -Entities $vm
$newoij = Get-VBRJobObject -Job $Job -Name $vm.Name
$newoij.Info.Type = [Veeam.Backup.Model.CDbObjectInJobInfo+EType]::VssChild
$newoij.VssOptions.Enabled = $false
Set-VBRJobObjectVssOptions -Object $newoij -Options $newoij.VssOptions
The code above disables VSS processing for a single child object in the job but you can change any of the VssOptions for the object prior to running the Set-VBRJobObjectVssOptions cmdlet.
grigatkis
Influencer
Posts: 18
Liked: 5 times
Joined: Nov 30, 2020 11:29 am
Contact:

Re: VSS Options and Credentials for child objects

Post by grigatkis »

Thank you, that code snippet just saved me a whole lot of bother.
AlexL
Service Provider
Posts: 135
Liked: 13 times
Joined: Aug 24, 2010 8:55 am
Full Name: Alex
Contact:

Re: VSS Options and Credentials for child objects

Post by AlexL »

cool, saved me some time too, thanks, would be very nice though if a cmdlet was added to do this in a simpler (and supported) way instead of going thru dotnet, this feels like a hack.
david.domask
Product Manager
Posts: 3369
Liked: 796 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: VSS Options and Credentials for child objects

Post by david.domask »

@AlexL,

I haven't tested Job VSS Object cmdlets in long time, but I was under the impression that New-VBRJobVssoptions with the -ForObject parameter does this.
David Domask | Product Management: Principal Analyst
AlexL
Service Provider
Posts: 135
Liked: 13 times
Joined: Aug 24, 2010 8:55 am
Full Name: Alex
Contact:

Re: VSS Options and Credentials for child objects

Post by AlexL »

No, it doesn't, the issue is usually that you select a folder, resourcepool or some other container for the job selection, not individual vm's.
You can enable or disable application aware backups thru code, default vss options can be changed with cmdlets, so far so good.
But, then you want to give a single vm within that folder different settings than the default.
In the GUI, you select add, add the wanted object in question, set options.
In powershell you CAN set vss options for an existing jobobject (eg the folder) but you cannot ADD the object to the vss settings. After it is added either in the GUI or with the above code you can set vss options. While the above code works fine, it is sort of a hack, there are so many cmdlets, this is one of the few that is missing.
On the other hand, if for example you would have a job with 3 individual VM's as a selection then you could set vss options with existing cmdlets.

At least that is my understanding, then again, I could be wrong.
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests