Using powershell to set VSS creds

PowerShell script exchange

Using powershell to set VSS creds

Veeam Logoby pizzim13 » Fri Jun 24, 2011 7:27 pm

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 viewtopic.php?f=2&t=3459#p14046

Any suggestions?
pizzim13
Enthusiast
 
Posts: 86
Liked: 6 times
Joined: Thu Apr 21, 2011 7:37 pm

Re: Using powershell to set VSS creds

Veeam Logoby Sethbartlett » Sat Jun 25, 2011 11:36 pm

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.
Sethbartlett
Expert
 
Posts: 282
Liked: 25 times
Joined: Wed Nov 10, 2010 6:51 pm
Full Name: Seth Bartlett

Re: Using powershell to set VSS creds

Veeam Logoby pizzim13 » Mon Jun 27, 2011 12:47 pm

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"
pizzim13
Enthusiast
 
Posts: 86
Liked: 6 times
Joined: Thu Apr 21, 2011 7:37 pm

Re: Using powershell to set VSS creds

Veeam Logoby Sethbartlett » Mon Jun 27, 2011 8:33 pm

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.
Sethbartlett
Expert
 
Posts: 282
Liked: 25 times
Joined: Wed Nov 10, 2010 6:51 pm
Full Name: Seth Bartlett

Re: Using powershell to set VSS creds

Veeam Logoby pizzim13 » Mon Jun 27, 2011 8:42 pm

It is a bug in the cmdlet? Do you think it will be fixed via the next update to Veeam?
pizzim13
Enthusiast
 
Posts: 86
Liked: 6 times
Joined: Thu Apr 21, 2011 7:37 pm

Using Powershell to add VSS processing options

Veeam Logoby roniva » Tue Jul 12, 2011 1:16 pm

[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
roniva
Novice
 
Posts: 8
Liked: never
Joined: Wed Apr 20, 2011 5:23 pm
Full Name: Ron brown

Re: Using powershell to set VSS creds

Veeam Logoby Sethbartlett » Sat Jul 16, 2011 7:10 am

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.
Sethbartlett
Expert
 
Posts: 282
Liked: 25 times
Joined: Wed Nov 10, 2010 6:51 pm
Full Name: Seth Bartlett


Return to PowerShell



Who is online

Users browsing this forum: No registered users and 4 guests