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
And this works successfully (added "return $wincred")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
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