Quantcast
Channel: PowerShell.org » All Posts
Viewing all articles
Browse latest Browse all 13067

Reply To: Invoke-Command with ; in script

$
0
0

You’re not escaping your double-quotes properly. To escape double quotes, either use a pair of double-quotes or use the backtick character. For example:

“”"Hello”"” # Outputs: “Hello”

“`"Hello`”" # Outputs: “Hello”

In contrast, using backslashes like you are will just generate an error because PowerShell doesn’t treat those as escaped double-quotes:

PS C:\> “\”Hello\”"
At line:1 char:4
+ “\”Hello\”"
+ ~~~~~~~~
Unexpected token ‘Hello\”"‘ in expression or statement.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : UnexpectedToken


Viewing all articles
Browse latest Browse all 13067

Trending Articles