PowerShell script exchange
Post Reply
Superkikim
Influencer
Posts: 16
Liked: 2 times
Joined: Jul 15, 2010 9:26 pm
Contact:

Set-VBRJobVssOptions -Options -Credentials weird behavior

Post by Superkikim »

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: Jul 15, 2010 9:26 pm
Contact:

Re: Set-VBRJobVssOptions -Options -Credentials weird behavio

Post by Superkikim »

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
veremin
Product Manager
Posts: 20397
Liked: 2298 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Set-VBRJobVssOptions -Options -Credentials weird behavio

Post by veremin »

Those parameters belong to different parameter sets and therefore cannot be used simultaneously .
Post Reply

Who is online

Users browsing this forum: No registered users and 23 guests