Implementing ParameterSets in PowerShell Cmdlet Development
===

I am trying to create a cmdlet in powershell that looks like the following:

    GET-XYZ -FIRST <string[]> -SECOND

-*FIRST* : I want it to be one out of 3 parameters. Exactly one of these parameters should be specified (not more or less )- mandatory

-*SECOND* : more than one switch (at most one specified) but the values depend on the FIRST attribute.

For example, say I want to use -A for -*FIRST*   

    GET-XYZ -A "asdasd"

then my available -`SECOND` can only be -A1, -A2 , or -A3

On the other hand, say I want to use -B for *-FIRST*, then my available *-SECOND* could be -B1, -B2, and -A1.

I realize that I can create parameter set for *-FIRST* but for *SECOND* I am not sure if I should just manually check with if statements for validation or if there is a way to define parameter sets within other parameter sets.


*-FIRST* example:

 

      [Parameter(Position = 1, Mandatory = true,
               ParameterSetName = "A")]
            public string A{
                get { return a; }
                set { a= value; }
            }
            private string a;
    
    
            [Parameter(Position = 1, Mandatory = true,
              ParameterSetName = "B")]   
            public string B
            {
                get { return b; }
                set { b= value; }
            }
            private string b;
    
            
    
            [Parameter(Position = 1, Mandatory = true,
            ParameterSetName = "C")]
            public string C
            {
                get { return c; }
                set { c= value; }
            }
            private string c;

Should *-SECOND* just be different switches defined and I check manually that at most one is set and display results accordingly?

Thanks



