The ValueFromRemainingArguments property

Setting the ValueFromRemainingArguments property allows a parameter to consume all of the other arguments supplied for a command. This can be used to make an advanced function act in a similar manner to a basic function.

For example, this basic function will fill the Parameter1 parameter with the first argument, and will ignore all others. The extra values are added to the $args automatic variable and are listed in the UnboundArguments property of the $MyInvocation automatic variable:

function Test-BasicBinding {    param (        $Parameter1    )    $MyInvocation.UnboundArguments}

Calling the function with non-existent parameters will not raise an error. The additional values will be added to the UnboundArguments ...

Get Mastering Windows PowerShell Scripting - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.