Using [parameter(ValueFromRemainingArguments=$true)] one can get all the remaining arguments passed to the function into a variable as a list.
How can I
This is tricky because using [Parameter(ValueFromRemainingArguments=$true)] means this is an advanced function, and $args cannot be used in advanced functions.
But if you want a hashtable of all the specified parameters and their values, you could simply use $PSBoundParameters, like so :
function foo {
[cmdletbinding()]
param(
[Parameter(Position=0)]
$Name,
[Parameter(Position=1,ValueFromRemainingArguments=$true)]
$LastName
)
"PSBoundParameters : "
$PSBoundParameters
}
foo -Name Mike Jordan Jones
This results in the following :
PSBoundParameters :
Key Value
--- -----
Name Mike
LastName {Jordan, Jones}
Is this what you are trying to achieve ?