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

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -