PowerShell: Here-String

By Xah Lee. Date: . Last updated: .

What is Here-String

Here-string (aka heredoc) is a syntax for quoting long multi-lines text. There are two syntaxes.

APOSTROPHE delimiter

$x = @'
long string here.
everything is literal
variable $n are not intepreted
can contain many quotes "" '' tick ` or slashes / \
'@

QUOTATION MARK delimiter

$x = @"
long string here
may have multiple lines
some variable $n cats
can contain many quotes "" '' tick ` or slashes / \
"@

The beginning and end quotation syntax must be on their own lines.

PowerShell, string and regular expression