PowerShell: Here-String

By Xah Lee. Date: .

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

Use single quote if you want everything literal.

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

Use double quote if you want $ variable or expression expanded:

$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