The doubled-up doubles quotes inside a double-quoted string is a way to insert a double quote. The updated version of echoargs.exe shows this a bit more clearly as it shows you the command line used to invoke the exe:
PS> echoargs " ""1"" 2 3 ""4 5 6"" 7 8 9"
Arg 0 is < 1 2 3 4>
Arg 1 is <5>
Arg 2 is <6 7 8 9>
Command line:
"C:\...\Modules\Pscx\Apps\EchoArgs.exe" " "1" 2 3 "4 5 6" 7 8 9"
If you take that command line (after it has been parsed by PowerShell) you get the same result in CMD.exe:
CMD> EchoArgs.exe " "1" 2 3 "4 5 6" 7 8 9"
Arg 0 is < 1 2 3 4>
Arg 1 is <5>
Arg 2 is <6 7 8 9>
Command line:
C:\...\Modules\Pscx\Apps\EchoArgs.exe " "1" 2 3 "4 5 6" 7 8 9"
As to why .NET or the C++ startup code parses the command line that way, I'm not entirely sure. This MSDN topic covers it a bit and if you look at the examples at the bottom of the topic, you will see some equally weird parsing behavior e.g. a\\\b d"e f"g h
gives a\\\b
, de fg
and h
.