-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Description
What I'm looking for is the ability to use a parameter to pass a variable, yet be able to act similar to a switch. Essentially...
No parameter:
PS>FunctionName
Or, parameter used like a switch where it will utilize a default value
PS>FunctionName -Parameter
Or, parameter used with a specified override to the default value
PS>FunctionName -Parameter 123
The idea is that I have a need for a function to accept multiple switch style inputs to say enable/disable, use/don't-use a particular feature. To that end a switch parameter works fine. However, many of the parameters are not only a true/false but also a variable, and I want to be able to provide the user a way to override the default value. A second parameter could be specified and required with dynamic parameters, to which the the input might look as follows...
PS>FunctionName -Parameter -ParameterOverride 123
But, this is clunky at best and considering the function I'm presently trying to work with has need for 8 parameters of this style it's down right ugly to use from the users perspective.