Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create a multiline string using a here-string.
PowerShell
$text = @[1] This is line one. This is line two. "@
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using "@ instead of @" to start the here-string.
Using single quotes which create a literal string without variable expansion.
✗ Incorrect
In PowerShell, a here-string starts with @" and ends with "@ for double-quoted strings.
2fill in blank
mediumComplete the code to end the here-string correctly.
PowerShell
$text = @" Line one Line two [1]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Ending with @" instead of "@.
Adding extra spaces after the end marker.
✗ Incorrect
A here-string started with @" must end with "@ on its own line.
3fill in blank
hardFix the error in the here-string declaration to allow variable expansion.
PowerShell
$name = "Alice" $message = [1] Hello, $name! "@
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using single-quoted here-string which treats variables as plain text.
Mixing start and end markers.
✗ Incorrect
Double-quoted here-strings (@" ... "@) allow variable expansion, single-quoted (@' ... '@) do not.
4fill in blank
hardFill both blanks to create a literal here-string that does not expand variables.
PowerShell
$name = "Bob" $text = [1] Hello, $name! [2]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using double quotes which expand variables.
Mismatching start and end markers.
✗ Incorrect
Single-quoted here-strings start with @' and end with '@, preserving the text literally without variable expansion.
5fill in blank
hardFill all three blanks to create a here-string with variable expansion and assign it to $greeting.
PowerShell
$user = "Eve" $greeting = [1] Hello, [2]! [3]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using single quotes which prevent variable expansion.
Using the variable name inside quotes which treats it as text.
✗ Incorrect
Start the here-string with @" and end with "@ to allow variable expansion. Use the variable name $user inside the string.