PowerShell script exchange
Post Reply
pizzim13
Enthusiast
Posts: 94
Liked: 6 times
Joined: Apr 21, 2011 7:37 pm
Contact:

Using powershell to set VSS creds

Post by pizzim13 »

I am using the following code to set the vss options for a Veeam job, but it throws an error when it comes to set the credentials:

Code: Select all

$VSSJobOptions = $JobObj.GetVssOptions()
$VSSJobOptions.Enabled = $true
$VSSJobOptions.IgnoreErrors = $false
$VSSJobOptions.GuestFSIndexingType = "EveryFolders"
$VSSJobOptions.Credentials = [Veeam.Backup.Common.CCredentials]::CreateEmpty()
$VSSJobOptions.Credentials.UserName = "domain\admin"
$VSSJobOptions.Credentials.Password = "xxxxx"
$JobObj.SetVssOptions($VSSJobOptions)
Error:

Code: Select all

Cannot find an overload for "CreateEmpty" and the argument count: "0".
At line:29 char:77
+ $VSSJobOptions.Credentials = [Veeam.Backup.Common.CCredentials]::CreateEmpty <<<< ()
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest
 
Property 'UserName' cannot be found on this object; make sure it exists and is settable.
At line:30 char:28
+ $VSSJobOptions.Credentials. <<<< UserName = "domain\admin"
    + CategoryInfo          : InvalidOperation: (UserName:String) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound
 
Property 'Password' cannot be found on this object; make sure it exists and is settable.
At line:31 char:28
+ $VSSJobOptions.Credentials. <<<< Password = "xxxxx"
    + CategoryInfo          : InvalidOperation: (Password:String) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound
For the code I am following the example from http://www.veeam.com/forums/viewtopic.p ... 459#p14046

Any suggestions?
Sethbartlett
Veteran
Posts: 282
Liked: 26 times
Joined: Nov 10, 2010 6:51 pm
Full Name: Seth Bartlett
Contact:

Re: Using powershell to set VSS creds

Post by Sethbartlett »

Could you please send more of the code before $VSSJobOptions = $JobObj.GetVssOptions() so we can see the whole script?
Skype: Sethbartlett88 - Make sure to label who you are and why you want to add me ;)
Twitter: @sethbartlett
If my post was helpful, please like it. Sometimes twitter is quicker to hit me up if you need me.
pizzim13
Enthusiast
Posts: 94
Liked: 6 times
Joined: Apr 21, 2011 7:37 pm
Contact:

Re: Using powershell to set VSS creds

Post by pizzim13 »

Just trying to learn the Veeam cmdlet basics to build out something much more complex.

Code: Select all

#variables for job creatation
$vbrserver = Get-VBRServer | Where {$_.Type -eq "Local"}
$CreateJobName = "Test"
$BackupDir = "c:\backup"
$VMs = "vm-test"

#Create Job
Add-VBRBackupJob -Name $CreateJobName -Type VDDK -Server $vbrserver -Folder $BackupDir -Objects $VMs

$JobObj = Get-VBRJob | where {$_.name -eq $CreateJobName}

#Set job options
$JobOptions = $JobObj.GetOptions()
$JobOptions.VDDKMode = "san"
$JobOptions.EmailNotification = $true
$JobOptions.Templates = $true
$JobOptions.TransformIncrementsToSyntethic = $true
$JobObj.SetOptions($JobOptions)

#VSS options for windows jobs
$VSSJobOptions = $JobObj.GetVssOptions()
$VSSJobOptions.Enabled = $true
$VSSJobOptions.IgnoreErrors = $false
$VSSJobOptions.GuestFSIndexingType = "EveryFolders"
$VSSJobOptions.Credentials = "Veeam.Backup.Common.CCredentials"
$VSSJobOptions.Credentials.UserName = "domain\admin"
$VSSJobOptions.Credentials.Password = "xxxxx"
$JobObj.SetVssOptions($VSSJobOptions)
All of the code works sans:

Code: Select all

$VSSJobOptions.Credentials = "Veeam.Backup.Common.CCredentials"
$VSSJobOptions.Credentials.UserName = "domain\admin"
$VSSJobOptions.Credentials.Password = "xxxxx"
Sethbartlett
Veteran
Posts: 282
Liked: 26 times
Joined: Nov 10, 2010 6:51 pm
Full Name: Seth Bartlett
Contact:

Re: Using powershell to set VSS creds

Post by Sethbartlett »

You will want to set credentials manually currently as there seems to be an issue with the way the passwords are stored for the credentials. You also would need to do "$VSSJobOptions.Credentials = [Veeam.Backup.Common.CCredentials]::CreateEmpty($true)

The issue is that when you do $VssJobOptions.Credentials.Password = "xxxx", the password will be saved in plain text and not hashed properly, you will want to set the password in the GUI currently.
Skype: Sethbartlett88 - Make sure to label who you are and why you want to add me ;)
Twitter: @sethbartlett
If my post was helpful, please like it. Sometimes twitter is quicker to hit me up if you need me.
pizzim13
Enthusiast
Posts: 94
Liked: 6 times
Joined: Apr 21, 2011 7:37 pm
Contact:

Re: Using powershell to set VSS creds

Post by pizzim13 »

It is a bug in the cmdlet? Do you think it will be fixed via the next update to Veeam?
roniva
Novice
Posts: 8
Liked: never
Joined: Apr 20, 2011 5:23 pm
Full Name: Ron brown
Contact:

Using Powershell to add VSS processing options

Post by roniva »

[merged]

We have a backup job that will backup all VM's in a given folder. The folder ends up containing a mix of Windows and Linux VM's. I currently go into the GUI and manually add the VM to the guest processing settings list and then manually set it to disable application processing and indexing. I looked through the options available in Get-VBRJobVssOptions and they just seem to be the options on the main VSS page and for the default object in the guest processing settings but not for any of the manually added items.

Has anyone found a way to add a VM to the guest processing settings list and set its options using the Veeam Powershell cmdlets? My ultimate goal in all of this would be to add some code to the bottom of my linux VM deployment script that would add itself to the vss list and set the options so I wouldn't have to worry about setting in manually.

-Ron
Sethbartlett
Veteran
Posts: 282
Liked: 26 times
Joined: Nov 10, 2010 6:51 pm
Full Name: Seth Bartlett
Contact:

Re: Using powershell to set VSS creds

Post by Sethbartlett »

As a response back to this thread to answer the initial question, I have found a solution.

Code: Select all

$Credentials = New-Object -TypeName Veeam.Backup.Common.CCredentials -ArgumentList "User","Password",0,0
From here, you can then do:

Code: Select all

$VSSJobOptions.Credentials = $Credentials
This will also allow you to easily set the same VSS Credentials across all your jobs or change them if need be.
Skype: Sethbartlett88 - Make sure to label who you are and why you want to add me ;)
Twitter: @sethbartlett
If my post was helpful, please like it. Sometimes twitter is quicker to hit me up if you need me.
Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests