I want to execute a command from powershell, which in turn executes a command on a foreign server, using plink. But this only works if I do not have ' or " in the command, otherwise Powershell jumps in and prints exceptions.
Example:
Invoke-Expression "$plinkPath -ssh $username@$host 'echo well...; echo hello'"
gives
well...
hello
. But what if I want to echo both ' and ", say
Invoke-Expression "$plinkPath -ssh $username@$host 'echo well...; echo hello, my "friend" 'brutus'!'"
to get
well...
hello, my "friend" 'brutus'!
?
Edit: Extension, I want to have a $.
well...
hello, my "friend" 'brutus', you $insult!