I wish to run the command:
mocha -i -g 'database|network|skip'
network : The term 'network' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path
STOP PARSING: --%
The stop-parsing symbol (--%), introduced in Windows PowerShell 3.0,
directs Windows PowerShell to refrain from interpreting input as
Windows PowerShell commands or expressions.
mocha --% -i -g 'database|network|skip'
The stop-parsing symbol is effective only until the next newline or
Using an example with
find you will get similar results.
find /c "this|that|andtheotherthing" C:\temp\EventCombMT.txt
find : FIND: Parameter format not correct At line:1 char:1 + find /c "this|that|andtheotherthing" C:\temp\EventCombMT.txt + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (FIND: Parameter format not correct:String) , RemoteException + FullyQualifiedErrorId : NativeCommandError
Pretty sure this is because the quotes are consumed by the PowerShell interpreter and that leave your
mocha command with an unquoted string. Doubling up the quotes is another was to prevent this.
find /c '"this|that|andtheotherthing"' C:\temp\EventCombMT.txt
It seems this is not the case with mocha? In comments it was determined that we need to reverse the quote set from that seen in the
There are better ways to call external commands as you have seen in your linked post. Like using the call operator and a hashtable. You would still have to address the quotes though. You could escape a set of double quotes as well to get a similar effect.
find /c "`"this|that|andtheotherthing`"" C:\temp\EventCombMT.txt
For this to be correct though it does not really match the error you are getting. While I am correct about a solution I might be wrong about my interpretation of the issue. PowerShell should not care about the pipe character regardless of how it is quoted. That is what the quotes are for.