PowerShell: Quote String

By Xah Lee. Date: . Last updated: .

String is a sequence of characters. There are 3 syntax to write string literals.

Single Quoted, Literal String

$x = 'some
thing'

echo $x

To include a single quote inside single quoted string, use two single quotes.

# double single quote becomes a single quote
$x = 'don''t'
$x -eq "don't"
# backslash is literal, GRAVE ACCENT also literal
$x = 'a\n`nb'

Double Quoted String (Expandable String)

Here-String

PowerShell String