Set-VBRJobVssOptions -Options -Credentials weird behavior

PowerShell script exchange

Set-VBRJobVssOptions -Options -Credentials weird behavior

Veeam Logoby Superkikim » Thu Feb 02, 2017 10:51 pm

Hi all,

Can anyone explain why is there a difference in behavior between two below scripts ?

Only difference is that in second script, I've added "return $wincred" before to Set-VBRJobVSSOptions.

I lost quite a lot of time on this, and I really don't get it.

Code: Select all
$jobname="myjobname"
$cred="mycredentials"
$wincred=Get-VBRCredentials | where {$_.UserNameOnly -Like $cred}
$job=Get-VBRJob -name $jobname

$options=Get-VBRJobVssOptions -Job $job
$options.enabled = $true
$options.WinGuestFSIndexingOptions.Type = "EveryFolders"
Set-VBRJobVssOptions -Job $job -Options $options -Credentials $wincred


Returns

Set-VBRJobVssOptions : Parameter set cannot be resolved using the specified named parameters.
At \\bercbru-rbk01\orca\scripts\ttest1.ps1:10 char:1
+ Set-VBRJobVssOptions -Job $job -Options $options -Credentials $wincred
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Set-VBRJobVssOptions], ParameterBindingException
+ FullyQualifiedErrorId : AmbiguousParameterSet,Veeam.Backup.PowerShell.Command.SetVBRJobVssOptions


And this works successfully (added "return $wincred")

Code: Select all
$jobname="myjobname"
$cred="mycredentials"
$wincred=Get-VBRCredentials | where {$_.UserNameOnly -Like $cred}
$job=Get-VBRJob -name $jobname

$options=Get-VBRJobVssOptions -Job $job
$options.enabled = $true
$options.WinGuestFSIndexingOptions.Type = "EveryFolders"
return $wincred
Set-VBRJobVssOptions -Job $job -Options $options -Credentials $wincred
Superkikim
Influencer
 
Posts: 16
Liked: 2 times
Joined: Thu Jul 15, 2010 9:26 pm

Re: Set-VBRJobVssOptions -Options -Credentials weird behavio

Veeam Logoby Superkikim » Thu Feb 02, 2017 11:10 pm

For instance, second does not work, however it does not return the error message ! Even weirder.

I ended up specifying Credential and Options in two separate commands:

Code: Select all
#$options.WinGuestFSIndexingOptions.Type = "EveryFolders"
Set-VBRJobVssOptions -Job $jobname -Options $options
Set-VBRJobVssOptions -Job $jobname -Credential $wincred
Superkikim
Influencer
 
Posts: 16
Liked: 2 times
Joined: Thu Jul 15, 2010 9:26 pm

Re: Set-VBRJobVssOptions -Options -Credentials weird behavio

Veeam Logoby v.Eremin » Fri Feb 03, 2017 11:17 am

Those parameters belong to different parameter sets and therefore cannot be used simultaneously .
v.Eremin
Veeam Software
 
Posts: 13724
Liked: 1027 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin


Return to PowerShell



Who is online

Users browsing this forum: No registered users and 1 guest