This topic contains 3 replies, has 3 voices, and was last updated by
September 26, 2018 at 10:22 am #112691ParticipantPoints: 0Rank: Member
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?
September 26, 2018 at 1:48 pm #112738ParticipantPoints: 0Rank: Member
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:
September 28, 2018 at 6:40 am #112867ParticipantPoints: 0Rank: Member
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.
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:
cmdlet Get-xxxEquipmentManufacturingDef at command pipeline position 1
Supply values for the following parameters:
September 28, 2018 at 12:32 pm #112886ParticipantPoints: 1Rank: Member
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. 🙂
You must be logged in to reply to this topic.