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

VSS Options and Credentials for child objects

Post by tsightler » 5 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: 14
Liked: 2 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.
Post Reply

Who is online

Users browsing this forum: No registered users and 9 guests