July 2017
Intermediate to advanced
648 pages
31h 9m
English
As mentioned in the first recipe in this chapter, PowerShell uses quoting rules to determine how variables should be handled inside a quoted string. When enclosing a simple variable inside a double-quoted string, PowerShell will expand that variable and replace the variable with the value of the string. Let's take a look at how this works by starting off with a simple example:
[PS] C:\>$name = "Bob"
[PS] C:\> "The user name is $name"
The user name is Bob
This is pretty straightforward. We stored the string value of Bob inside the $name variable. We then include the $name variable inside a double-quoted string that contains a message. When we hit return, the $name variable is expanded and we get back the message ...
Read now
Unlock full access