I try to invoke a PowerShell command within a batch file:
powershell -Command "(gc test.txt ) -replace ("~\[","`r`n[") | sc test.txt"
But it always fails with this error:
At line:1 char:29
+ (gc test.txt ) -replace (~\[,`r`n[) | sc test.txt
+ ~
Missing argument in parameter list.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordEx
ception
+ FullyQualifiedErrorId : MissingArgument
I try with single quotes for the replace strings:
powershell -Command "(gc test.txt ) -replace ('~\[','`r`n[') | sc test.txt"
But the backtick escape character is treated like any other text character when it appears within a string enclosed in single quotes.