I have scoured the escape rules for PS but I cannot wrap my head around why the only work some of the time. For example, if I am passing a String argument to a cmdlet, it seems like all bets are off.
PowerShell 'echo "Hello there"'
I would expect this to yield an output of: Hello there
, but instead PowerShell completely ignores the double quotes and no matter which escape sequence I use, it refuses to acknowledge that they even exist in the String. Of course, the above is just an example. It doesn't matter which cmdlet I'm using, whenever a String is passed, all escape rules seemingly flat out do not apply. The same goes for passing a String to Node.JS, through PowerShell:
node -p 'console.log("Hello")'
This throws an error, once again because PowerShell decides to throw away my double-quotes and pretend they're not there.
Interestingly enough, if I swap the quotes around, like this:
node -p "console.log('Hello')"
It produces the correct result, though any double-quotes inside the String immediately break it. It's so bizarre that the escape rules appear not to apply to String arguments. Am I misunderstanding the rules? Is there any way to use double-quotes inside single-quoted String arguments that PS won't completely ignore?
Thanks for any insight.