February 2014
Intermediate to advanced
374 pages
8h 12m
English
In PowerShell, you can define a string with single or double quotes. There is a difference between these two methods. In a string with single quotes, variables and subexpressions are not expanded; while in a string with double quotes, variables and subexpressions are expanded.
Let's look at an example of variable expansion in a double-quoted string:
PowerCLI C:\> $Number = 3 PowerCLI C:\> "The number is: $Number" The number is: 3
In the preceding example, the string is defined with double quotes and the $Number variable is expanded. Let's see what happens if you use single quotes:
PowerCLI C:\> $Number = 3 PowerCLI C:\> 'The number is: $Number' The number is: $Number
Using a single-quoted string, ...
Read now
Unlock full access