Is there a limit to the number of parameter sets a cmdlet can have? I made a cmdlet that has 56 switch parameters, and I want each of them to be mandatory in its own set of parameters. For some reason, powershell groups the (n + 1) th with the 1st, the (n + 2) th with the second, etc., ending with no more than n parameter sets; if I counted n correctly, there were 32. This looks like my cmdlet:
[Cmdlet(VerbsCommon.Get, "Foo")] public class GetFoo : PSCmdlet { [Parameter(ValueFromPipeline = true)] public string ParamA {get;set;} [Parameter(ValueFromPipelineByPropertyName = true)] public string ParamB {get;set;} [Parameter] public string ParamC {get;set;} [Parameter(ParameterSetName = "Group1", Mandatory = true)] public SwitchParameter Param1 {get;set;} [Parameter(ParameterSetName = "Group2", Mandatory = true)] public SwitchParameter Param2 {get;set;} . . . [Parameter(ParameterSetName = "Group56", Mandatory = true)] public SwitchParameter Param56 {get;set;} }
Expected:
PS> Get-Help Get-Foo Get-Foo -Param1 [-ParamA <string>] [-ParamB <string>] [-ParamC <string>] Get-Foo -Param2 [-ParamA <string>] [-ParamB <string>] [-ParamC <string>] . . . Get-Foo -Param56 [-ParamA <string>] [-ParamB <string>] [-ParamC <string>]
Actual:
PS> Get-Help Get-Foo Get-Foo -Param1 -Param33 [-ParamA <string>] [-ParamB <string>] [-ParamC <string>] Get-Foo -Param2 -Param34 [-ParamA <string>] [-ParamB <string>] [-ParamC <string>] . . . Get-Foo -Param24 -Param56 [-ParamA <string>] [-ParamB <string>] [-ParamC <string>] Get-Foo -Param25 [-ParamA <string>] [-ParamB <string>] [-ParamC <string>] . . . Get-Foo -Param32 [-ParamA <string>] [-ParamB <string>] [-ParamC <string>]
I rack my brains and donβt see what happened with the way I created the cmdlet; I do not see this behavior if I reduce the number of parameter sets. Any advice would be appreciated.
Dezot source share