Recall & Review
beginner
What is a string in PowerShell?
A string is a sequence of characters used to represent text. In PowerShell, strings are enclosed in single ('') or double ("") quotes.
Click to reveal answer
beginner
How do single quotes and double quotes differ in PowerShell strings?
Single quotes ('') create literal strings where variables are not expanded. Double quotes ("") allow variable interpolation, meaning variables inside the string are replaced with their values.
Click to reveal answer
beginner
Example: What will this output? <br>
$name = 'Sam' Write-Output 'Hello, $name'
It will output: Hello, $name <br>Because single quotes do not expand variables, the output shows the variable name literally.
Click to reveal answer
beginner
Example: What will this output? <br>
$name = 'Sam' Write-Output "Hello, $name"
It will output: Hello, Sam <br>Because double quotes allow variable interpolation, the variable $name is replaced with its value.
Click to reveal answer
intermediate
How can you include a literal dollar sign ($) in a double-quoted string without triggering variable interpolation?
Use the backtick (`) escape character before the dollar sign, like this: "Price is `$5". This prints: Price is $5.
Click to reveal answer
Which quotes allow variable interpolation in PowerShell?
✗ Incorrect
Double quotes allow variables inside the string to be replaced with their values.
What will this output? <br>
$var = 10 Write-Output 'Value is $var'
✗ Incorrect
Single quotes do not expand variables, so $var is printed literally.
How do you escape a dollar sign in a double-quoted string?
✗ Incorrect
In PowerShell, the backtick (`) escapes special characters like $.
What type of string is this? <br>
'Hello, World!'
✗ Incorrect
Single quotes create literal strings where variables are not expanded.
Which is true about double-quoted strings in PowerShell?
✗ Incorrect
Double-quoted strings allow variables inside to be replaced with their values.
Explain the difference between single-quoted and double-quoted strings in PowerShell.
Think about how variables behave inside each type of quotes.
You got /4 concepts.
How do you include a literal dollar sign ($) in a double-quoted string without triggering variable interpolation?
Remember the escape character in PowerShell.
You got /3 concepts.