Search code examples
powershellarguments

How to get all arguments passed to function (vs. optional only $args)


$args returns only optional arguments. How can I get all function parameters?


Solution

  • $args returns any undeclared parameters, not optional parameters. So just don't declare parameters.

    In PowerShell v2, you can use $PSBoundParameters to get all parameters in a structured way.