PowerShell command line parameters and '--'

With PowerShell 3 you can use --% to stop the normal parsing PowerShell does.

.\abc.exe --% foo.txt -- bar --

A double hyphen instructs PowerShell to treat everything coming after as literal arguments rather than options, so that you can pass for instance a literal -foo to your script/application/cmdlet.

Example:

PS C:\> echo "-bar" | select-string -bar
Select-String : A parameter cannot be found that matches parameter name 'bar'.
At line:1 char:28
+ "-bar" | select-string -bar <<<<
    + CategoryInfo          : InvalidArgument: (:) [Select-String], ParameterBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.SelectStringCommand

vs.

PS C:\> echo "-bar" | select-string -- -bar

-bar

To avoid this behavior you must either quote ("--", '--') or escape (`--) the double hyphen.