WebJEA
WebJEA copied to clipboard
ParameterSetName and mandatory validtion
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 }
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.