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

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -