Options for reducing the number of parameters


I’m building a PowerShell module for an internal Rest-Api. My problem is that one particular controller offers a ton of optional properties to be set, so my function would end up with 50+ parameters.

What options do I have to reduce the number of parameters? I could use objects to group some of the parameters, but then users would have to read the documentation to know what the objects look like. (Or is it possible to get IntelliSense on the properties of a pscustomobject?)

I don’t really see a great way of handling this. Any ideas?

if part of parameters doesn’t mean explicit use (credentials, connection options, etc)
You can setup your code like PSSessionConfiguration, i.e. move options to different cmdlet and use it internally or
something like

$session = new-specialsession -options1 -options2 ...
invoke-specialapi -session $session -additional -option

I’d add that 50 isn’t so bad. Look at the ADUser commands - they have a ton. I’m not sure I’d see reduction as a goal, and certainly not “bundling” parameters and making them harder to discover and understand.

Also look to see if defining parameter sets can help reduce the number of parameters you’re dealing with at one time