0
0
PowerShellscripting~10 mins

Here-strings for multiline in PowerShell - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete 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'
A"""
B"@
C@"
D@'
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.
2fill in blank
medium

Complete 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'
A"@
B@"
C"'
D'@
Attempts:
3 left
💡 Hint
Common Mistakes
Ending with @" instead of "@.
Adding extra spaces after the end marker.
3fill in blank
hard

Fix 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'
A@'
B'@
C"@
D@"
Attempts:
3 left
💡 Hint
Common Mistakes
Using single-quoted here-string which treats variables as plain text.
Mixing start and end markers.
4fill in blank
hard

Fill 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'
A@'
B"@
C'@
D@"
Attempts:
3 left
💡 Hint
Common Mistakes
Using double quotes which expand variables.
Mismatching start and end markers.
5fill in blank
hard

Fill 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'
A@"
B$user
C"@
D'$user'
Attempts:
3 left
💡 Hint
Common Mistakes
Using single quotes which prevent variable expansion.
Using the variable name inside quotes which treats it as text.