Query regarding limit on maxmimum number of ParameterSets for powershell cmdlet?

Hi,

 

Can anyone please confirm if there is official limit on the maximum number of ParameterSets for a custom cmdlet? For our powershell module, we are facing issue in the cmdlets when the number of ParameterSets exceeds beyond 32.

 

On the basis of this, I have few questions:

1.) Is 32 the limit of maximum number of parametersets that a cmdlet can have?

2.) Is there any work around for this issue?

3.) Is there any plan to increase the number of parameterset in future powershell releases?

 

thanks,

Vinay Ravish

My initial reaction is that seems like way too many parameter sets for a single function and that you should be using a more modular approach. This is the only doc I see with a quick search that doesn’t have any indication of a limitation:

Once you get beyond 32, what is the behavior? Are they being ignored? Are you getting errors? You’ll need to gather as much detail as possible and open an issue here:

Issue statement:
I have a Get cmdlet, which has a default parameterSet named as “All”. As per our implementation, any “Get” cmdlet in our module should run without any parameters(because there are no mandatory parameters under “All” ParameterSet). This rule is followed by all our Get cmdlets and cmdlets worked fine. But after the addition of 33rd parameterSet, “Get” cmdlet start asking for mandatory parameter from a parameterSet(just an observation: last parameterset in sequence). So cmdlet execution basically switched from default parameterSet (i.e. “All”) to another parameterSet(last parameterset in sequence) and asks the mandatory parameter specified in that particular parameterSet.

Expected behavior:
C:> Get-xxxEquipmentManufacturingDef
cmdlet should return objects of of type “EquipmentManufacturingDef”. This cmdlet worked fine until the parameterSets were less than 32.
New Behavior which is causing issue:
C:> Get-xxxEquipmentManufacturingDef

cmdlet Get-xxxEquipmentManufacturingDef at command pipeline position 1
Supply values for the following parameters:
EquipmentTpmCapProvider:

You need to explicitly specify the default parameter set in the cmdletbinding statement:

[CmdletBinding(DefaultParameterSetName = 'All')]
param(
# ...
)

But in all honesty you probably need to look at breaking that function into several pieces. 32 parameter sets is getting to be far too many; most standard cmdlets have less than 10 sets in total, and a majority of them only have 4 or less.

One function for one task. :slight_smile: