All, Forgive me I am a newbie for the Power Shell
, Currently I was reading book Windows PowerShell CookBook
try to get start with it. So far, Everything make sense to me except one thing, I was totally confused with the Positional Parameter
to Cmdlet
.
For example: Select-String
The syntax is following :
Select-String [-Pattern] <String[]> [-Path] <String[]> [-AllMatches] [-CaseSensitive] [-Context <Int32[]>]
[-Encoding <String>] [-Exclude <String[]>] [-Include <String[]>] [-List] [-NotMatch] [-Quiet] [-SimpleMatch]
[<CommonParameters>]
Select-String [-Pattern] <String[]> [-AllMatches] [-CaseSensitive] [-Context <Int32[]>] [-Encoding <String>]
[-Exclude <String[]>] [-Include <String[]>] [-List] [-NotMatch] [-Quiet] [-SimpleMatch] -InputObject <PSObject>
[<CommonParameters>]
Select-String [-Pattern] <String[]> [-AllMatches] [-CaseSensitive] [-Context <Int32[]>] [-Encoding <String>]
[-Exclude <String[]>] [-Include <String[]>] [-List] [-NotMatch] [-Quiet] [-SimpleMatch] -LiteralPath <String[]>
[<CommonParameters>]
I can pass the parameter value to the Cmdlet
directly by ignoring the parameter name . like below:
"Hello World"|Select-String .
Based on the concept of Positional parameter
,Because the parameter -Pattern
is the first parameter. the value .
can match the parameter -Pattern
. It is ok for me to understand.
But When I try this command line "hello world" | Select-String -AllMatches .
the value .
is not in the first. Why the Select-String
can know it and work out the result ? Could someone please tell me more to understand it well? thanks.