SAPIEN Solutions

SAPIEN homepage
PrimalScript script editor+ide
PrimalScope script debugger
Free Tools script utilities
SAPIEN Press tech books
ScriptingAnswers.com learn+share
ScriptingOutpost.com online store
Blog.Sapien.com official blog
Contact Us

 

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.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Tags: ,

One Response to “Single quotes, not double”

  1. Jason Says:

    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

Leave a Reply


Entries (RSS) and Comments (RSS).