It's the first unnamed paramter. The position value tells the cmdlet which argument belongs to which parameter.
The command Select-String -allmatches .
links the -allmatches
switch to its parameter, and sets the .
as the first item in the $args
-array (arguments-array) since it doesn't have -parametername
in front of it.
Then because Select-String
includes a positional value for its parameters, the cmdlet knows that the first item in the arguments-array ($args[0]
) should be bound to the -Pattern
parameter.
If you'd like to understand this better, read the part about Parameter Position?
in the help-section by running:
Get-Help about_Parameters
Then notice that the -Pattern
parameter has position 1, as seen here:
Get-Help select-string -Parameter pattern
-Pattern <String[]>
Specifies the text to find. Type a string or regular expression. If you type a string, use the SimpleMatch parameter.
To learn about regular expressions, see about_Regular_Expressions.
Required? true
Position? 1
Default value
Accept pipeline input? false
Accept wildcard characters? false
Then run the following line to see how PowerShell binds the inputobject "hello world"
and the parameters and arguments.
Trace-Command -Expression { "Hello World" | Select-String -allmatches . } -Name ParameterBinding -PSHost