PowerShell Parameter Sets: Require either A or B to be set -


is there simple way have parameter set allows either or b not both specified?

e.g. script either accept:

.\simplescript.ps1 -a "str1" -x 1 -y 2 -z 3 

or

.\simplescript.ps1 -b "str2" -x 1 -y 2 -z 3 

but not:

.\simplescript.ps1 -a "str1" -b "str2" -x 1 -y 2 -z 3 

you can write cmdlet , use parameter sets.

have base documentation @ about functions advanced parameters

param (     [parameter(mandatory=$true,     parametersetname="witha")]     [string]     $a,      [parameter(mandatory=$true,     parametersetname="withb")]     [string]     $b,      [parameter(mandatory=$true)]     [int]     $x ... ) 

Comments

Popular posts from this blog

go - serving up pdfs using golang -

python - Best design pattern for collection of objects -

sharepoint online - C# CSOM SPView ListItemCollection did not update after I add new field in the SP view -