PowerShell Nested Here-String
Placing the following within a script will fail: $MyString = @' hello @' '@ bye '@ write-host $MyString The error returned is as follows: At C:\scripts\test.ps1:6 char:1 + '@ + ~~ The string is missing the terminator: '. + CategoryInfo : ParserError: (:) [], ParseException + FullyQualifiedErrorId : TerminatorExpectedAtEndOfString Prefixing the nested @' and '@ with a backtick (grave accent) does serve as an escape character, however it is also treated as literal, and therefore appears in the output of $MyString. Is there a correct way to escape a single quoted here-string within a single quote
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.