Hello
I do not believe what I want to achieve is possible with ParameterSetName but thought I would ask here.
Param(
[Parameter(ParameterSetName="A")]$Par1,
[Parameter(ParameterSetName="B")]$Par2,
$Par3,
$Par4
)
Now in the above example Par3 and Par4 belong to 'all' parameter sets. If you select -par1 on the command line -par2 is not available and visa versa, all OK so far.
what I want to do is also make Par3 and Par4 exclusive in other words if I select -Par3 I cannot select -Par4
But if I do the following
Param(
[Parameter(ParameterSetName="A")]$Par1,
[Parameter(ParameterSetName="B")]$Par2,
[Parameter(ParameterSetName="C")]$Par3,
[Parameter(ParameterSetName="D")]$Par4
)
each parameter is now exclusive i.e. if I select one I cannot select any of the others
but if I do the following; as I want to be able to select either Par3 or Par4 when selecting either Par1 or Par2, but if I select Par1 I do not want Par2 (and visa-versa) and if I select Par3 I do not want Par4 (and visa-versa)
Param(
[Parameter(ParameterSetName="A")]$Par1,
[Parameter(ParameterSetName="B")]$Par2,
[Parameter(ParameterSetName="A")]
[Parameter(ParameterSetName="B")]
[Parameter(ParameterSetName="C")]$Par3,
[Parameter(ParameterSetName="A")]
[Parameter(ParameterSetName="B")]
[Parameter(ParameterSetName="D")]$Par4
)
Now the issue with the above is Par3 and Par4 are both members of parameter set names A and B (in other words they have a parameter set name in common, meaning I can now select -Par3 AND -Par4 at the same time (which I do not want)
Therefore I can see how you can 'include' a parameter in a given parameter set name, but I do not see how I can exclude a parameter from one set and not another set without affecting your second exclusion (if you see what I mean)
Any advise most welcome
Thanks
AAnotherUser__