Tip: You can count the number of parameters passed in a function using the automatic variable $PSBoundParameters and the property Count:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
function Get-Something { Param ( [Parameter(Mandatory=$true, Position=0)] [string]$Param1, [Parameter(Mandatory=$true, Position=1)] [string]$Param2, [switch]$Param3 ) $PSBoundParameters.Count } |