WebJEA icon indicating copy to clipboard operation
WebJEA copied to clipboard

ParameterSetName and mandatory validtion

Open schwallers opened this issue 4 years ago • 1 comments

I don't think paramtersetname is working correctly. When using parametersets the mandatory setting validation is taking priority over the parametersets. The below param setting should make C mandatory if using A and optional if using B. Currently all 3 are mandatory and that results in an "AmbiguousParameterSet" error on submit.

param ( [parameter(ParameterSetName="AandC", mandatory=$true)] [switch]$a, [parameter(ParameterSetName="BandC", mandatory=$true)] [switch]$b, [parameter(ParameterSetName="AandC", mandatory=$true)] [parameter(ParameterSetName="BandC", mandatory=$false)] [switch]$c }

schwallers avatar Dec 03 '20 06:12 schwallers

ParameterSetName is not supported. Depending on your use case, it can be made to work, without the mandatory fields and doing validation within the function.

markdomansky avatar Dec 04 '20 03:12 markdomansky