February 2019
Intermediate to advanced
626 pages
15h 51m
English
Position defaults to -2147483648, the smallest possible value for Int32 (see [Int32]::MinValue). Unless an explicit permission is set, parameters may be bound in the order they are written in the parameter block. Setting the PositionalBinding property of CmdletBinding to false can be used to disable this behavior.
Automatic positional binding is shown in the following example:
function Test-Position { [CmdletBinding()] param ( [Parameter()] $Parameter1, [Parameter()] $Parameter2 ) '{0}-{1}' -f $Parameter1, $Parameter2}
When called, the command shows that Parameter1 and Parameter2 have been filled with the values supplied using position only:
PS> Test-Position 1 21-2
Automatic positional binding is available ...
Read now
Unlock full access