Tip: You can set the property DefaultParameterSetName of the CmdletBinding attribute.
ParameterSetName = allows you to specify the parameter set that a parameter belongs to.
In case there is no parameter set specified, the parameter belongs to all the parameters sets which are defined by the function.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
function Get-Something { [CmdletBinding(DefaultParameterSetName = 'Car')] Param ( [Parameter(ParameterSetName = 'Car')] [switch]$Car, [Parameter(ParameterSetName = 'Bus')] [switch]$Bus, [Parameter(ParameterSetName = 'Bike')] [switch]$Bike ) $PsCmdlet.ParameterSetName } |