Single quotes, not double
Use ’single quotation marks’ around string literals unless you explicitly need variable expansion. In PowerShell, single quotes are not expanded into variables:
$var = ‘Hello’
$result = ‘$var $var’
# $result contains ‘$var $var’
Double quotes are:
$var = ‘Hello’
$result = "$var $var"
# $result contains ‘Hello Hello’
To avoid unintended variable expansion, use single quotes unless you explicitly need the expansion feature.
Tags: double quotes, single quotes











July 17th, 2008 at 9:05 am
How do you surround a variable in double quotes for example
$path=”C:\documents and settings”
when i return the variable in the script i need it surrounded by double quotes.
$path –> returns c:\documents and settings
i need the return to be –> “C:\Documents and Settings”
Thanks,
Jason