April 7, 2010

What is the difference between single (‘) and double quotes (“) ?

With double quotes (“), variables in the string are expanded.

write-output "Starting engine from $pshome ..."
Will output :
Starting engine from C:\Windows\System32\WindowsPowerShell\v1.0 ...
To expand an expression use $(), ex:
Write-Output "the Powershell host is $($host.name)"

No comments:

Post a Comment