$args returns only optional arguments. How can I get all function parameters?
+3
A:
$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.
JasonMArcher
2009-04-23 18:00:31
A:
$PSBoundParameters gets you all the parameters that were "bound" along with the bound values in a hashtable, it doesn't get you the optional/extra arguments. That is what $args is for. AFAICT the only way to get what you want is to combine the two:
$allArgs = $PsBoundParameters.Values + $args
Keith Hill
2009-05-03 22:01:35