Understanding Quotes
PowerShell uses four different types of quotes. As an administrator, you are most interested in single ordinary and double ordinary quotes. A developer would be more interested in the here-strings. The four types of quotes are explained in the following table.
Single ordinary quotes: $a="Champs" 'World $a' => World $a |
In single quotes, variable names are not expanded and escape sequences are not interpreted. |
Double ordinary quotes: $a="Champs""World $a" => World Champs |
Inside double quotes, variable names are replaced with their values and PowerShell escape sequences are interpreted. |
Single here-strings: $b="Two" $x = @' " Easy as One $b Three ! " '@ $x produces: " Easy as One $b Three ! " |
In single here-strings, variable names are not expanded and escape sequences are not interpreted. A single here-string begins with @' and ends with '@. PowerShell here-strings are similar to here-documents in Perl. |
Double here-strings: $b="Two" $x = @" " Easy as One Two Three ! " "@ $x produces: " Easy as One Two Three ! " |
Inside double here-strings, variable names are replaced with their values and PowerShell escape sequences are interpreted. A double here-string begins with @" and ends with "@. PowerShell here-strings are similar to here-documents in Perl. |