Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

PowerShell Multiple Groups of Mutually Exclusive Parameters

$
0
0

So, I am not sure if what I am asking is even feasible given the limitations I have come across in the ParameterSetName property, but I figured I would ask.


Here's the deal.  I have two groups of three parameters that are mutually exclusive.  So lets say the first group is a way to receive remote computer(s) you want to connect to.  One way could be via the computer name, another a CSV, and finally, a session object.  If you choose to do one of these ways, you can not use the others, so they all must be in different ParameterSetName groups.


Next, lets say the my second set of three parameters are three things you want to do to these computers.  The catch is, all of these things are mutually exclusive.  So, just like with the first set, if you choose one thing, you can not choose any of the others in these groups.


Now, my question is. Is there anyway to keep the groups' parameters mutually exclusive of each other, while allowing a parameter from both groups to be set?


My experience so far has shown, that only one $PSCmdlet.ParameterSetName gets set, which would mean, that what I am asking is impossible within the Parameter block.  Meaning, you can only have one group of mutually exclusive variables.  Is there a way to overload the Parameter block to achieve what I am asking?


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>