PowerShell

Article by:
Date Published:
Last Modified:

Single Quotes Vs. Double Quotes

You can define strings in PowerShell with either single quotes or double quotes. What is the difference? The difference is that PowerShell does not perform interpolation with single quotes, but does perform interpolation with double quotes.

What is interpolation? This is where the PowerShell interpreter will look for valid string variable names inside the double quotes, and if found, will substitute the variable name with the string variables contents.

1
2
3
4
5
6
7
$str1 = ", world."

$singleQuotesStr = 'Hello $str1'
$doubleQuoteStr = "Hello $str1"

Write-Host $singleQuotesStr # Prints "Hello $str1", no interpolation occurred
Write-Host $doubleQuotesStr # Prints "Hello, world.", interpolation occurred

Authors

Geoffrey Hunter

Dude making stuff.

Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License .

Tags

    comments powered by Disqus