PowerShell script exchange
Post Reply
Andre09
Lurker
Posts: 2
Liked: never
Joined: Aug 05, 2020 3:07 pm
Full Name: Andre vG
Contact:

Change Guest processing credentials

Post by Andre09 »

Hi,

i need a script to change the credentials used for guest processing on all of my backup and all of my replication jobs.
can anyone help me?

i think "Set-VBRJobVSSOptions" should be the right one but didn't know how to use it as a script.

thanks in advance

regards, Andre
oleg.feoktistov
Veeam Software
Posts: 1918
Liked: 636 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Change Guest processing credentials

Post by oleg.feoktistov »

Hi Andre and Welcome to our Community Forums!

If you are after specifying common guest credentials for all processed objects in a job:

Code: Select all

$jobs = Get-VBRJob
$winCreds = Get-VBRCredentials -Name 'winCredsName'
foreach ($job in $jobs) {
  $objects = Get-VBRJobObject -Job $job
  $vssOptions = Get-VBRJobVSSOptions -Job $job
  $vssOptions.Enabled = $true
  $vssOptions.WinCredsId = $winCreds.Id
  Set-VBRJobVssOptions -Job $job -Options $vssOptions

} 

Else if you are after selecting specific credentials for each job object:

Code: Select all

$jobs = Get-VBRJob
$winCreds = Get-VBRCredentials -Name 'winCredsName'
$linuxCreds = Get-VBRCredentials -Name 'linuxCredsName'
foreach ($job in $jobs) {
  $objects = Get-VBRJobObject -Job $job
  $vssOptions = Get-VBRJobVSSOptions -Job $job
  $vssOptions.Enabled = $true
  Set-VBRJobVssOptions -Job $job -Options $vssOptions
  foreach ($object in $objects) {
    $entity = Find-VBRViEntity -Name $object.Name
    $vssObjectOptions = Get-VBRJobObjectVssOptions -ObjectInJob $object
    if ($entity.GuestInfo.IsUnixBased -eq $true) {
        $vssObjectOptions.LinCredsId = $linuxCreds.Id
    }
    else {
        $vssObjectOptions.WinCredsId = $winCreds.Id
    }
    Set-VBRJobObjectVssOptions -Object $object -Options $vssObjectOptions

  }
} 
My last example above is based on binary choice of credentials and depends on whether backed up client is of unix type or not.
If distinct credentials are needed for each job object, more validations are to come.

Best regards,
Oleg
Andre09
Lurker
Posts: 2
Liked: never
Joined: Aug 05, 2020 3:07 pm
Full Name: Andre vG
Contact:

Re: Change Guest processing credentials

Post by Andre09 »

Hi Oleg,
thank you for your answer.
My jobs only have one object each. I want to change the jobs with the Windows servers, but there are also Linux jobs that should stay the same...
Would that be right to put my account there? Does he see for himself if they are windows and only changes them?

Code: Select all

$jobs = Get-VBRJob
$winCreds = Get-VBRCredentials -Name 'DOMAIN\MYACCOUNT'
foreach ($job in $jobs) {
  $objects = Get-VBRJobObject -Job $job
  $vssOptions = Get-VBRJobVSSOptions -Job $job
  $vssOptions.Enabled = $true
  $vssOptions.WinCredsId = $winCreds.Id
  Set-VBRJobVssOptions -Job $job -Options $vssOptions

}
I have already executed your code but it does not change any login data, only a list with all jobs was displayed...

regards, Andre
jhoughes
Veeam Vanguard
Posts: 279
Liked: 112 times
Joined: Apr 20, 2017 4:19 pm
Full Name: Joe Houghes
Location: Castle Rock, CO
Contact:

Re: Change Guest processing credentials

Post by jhoughes »

Have you looked at the job options to verify no change?

First, you need to be sure that the line starting with $winCreds returned only a single credential object, or you need to filter down to one specific credential.

With the code capturing everything to variables, there would not be output from these get or set cmdlets. You would need to add a line into the loop to display your job options, or do that afterwards to verify the changes.

I would suggest working with 1 job until you have a successful test, before trying to modify all jobs.
Husband, Father, Solutions Architect, Geek Extraordinaire | @DenverVMUG, @AustinVMUG & @ATXPowerShell leader | VMware vExpert | Cisco Champion
oleg.feoktistov
Veeam Software
Posts: 1918
Liked: 636 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Change Guest processing credentials

Post by oleg.feoktistov »

Adding to what Joe mentioned, if you need to setup guest credentials for jobs with one object each, try the snippet below:

Code: Select all

$jobs = Get-VBRJob
$winCreds = Get-VBRCredentials -Name 'windowsCredentials'
foreach ($job in $jobs) {
  $object = Get-VBRJobObject -Job $job
  $vssOptions = Get-VBRJobVSSOptions -Job $job
  $vssOptions.Enabled = $true
  
  # Check if job object is of Unix type. If not, set guest credentials to windows-specific.
  
    $entity = Find-VBRViEntity -Name $object.Name
    if ($entity.GuestInfo.IsUnixBased -eq $false) {
        $vssOptions.WinCredsId = $winCreds.Id
        Set-VBRJobVssOptions -Job $job -Options $vssOptions
    }

 } 

As credentials object doesn't have type property available, you need to sort job objects by OS type and configure only those not UnixBased => Windows.


Thanks,
Oleg
Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests