Maximum Number of PowerShell Parameter Sets in Function

I have been working on a module which includes a function that has many options for how it can be executed. Through the flexibility of Parameter Sets I have been able to define in detail all of the available options and use the built in validation to minimise the amount of variable checking that I need to do in the main code block of the function.

However, I appear to have hit a limitation with regards to the number of distinct Parameter Sets that you can define. When I added my 33rd parameter set, the sets stopped being evaluated properly, and the Get-Help function –ShowWindow command showed some duplicate sets and only ever 32 combinations.

When I only have 32 parameter sets, everything works as it should, any more seems to break the functionality. This is using PowerShell 3.0.

I have not been able to find any documentation on the web to either confirm or deny this limitation.

Be the first to like.

4 thoughts on “Maximum Number of PowerShell Parameter Sets in Function

  1. I ran into the same issue. Now that PowerShell is open-sourced I could track this down to what seems to be a design decision:
    Each parameterset get assigned one bit of a 32-bit unsigned integer (uint32) as its ID. This implicitly limits the number of parametersets to 32.

    1. Unfortunately not. It appears to be the same in PowerShell 5 as well. Never did find anything documenting the limitation either.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.