Can a Powershell v2.0 dynamic parameter be at position 0? Can a Powershell v2.0 dynamic parameter be at position 0? powershell powershell

Can a Powershell v2.0 dynamic parameter be at position 0?


After playing around with this a little bit, I discovered that adding the ValueFromRemainingArguments Parameter Attribute to the $InputObject parameter seems to get closest to the desired behavior; however, I am not entirely sure why.

    Param (...    [Parameter(ParameterSetName="set1",               Position=1,               ValueFromPipeline=$true               ValueFromRemainingArguments=$true)]        $InputObject,    ...)


Another approach that worked for me is to set the PositionalBinding argument of the CmdletBinding attribute to $False. Then if only the dynamic parameters have a Position set, then they get the positional values set correctly.

This of course assumes that you don't want any of the static parameters to have a position.