0
0
PowerShellscripting~5 mins

Here-strings for multiline in PowerShell - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a here-string in PowerShell?
A here-string is a way to create multiline strings easily. It starts with @" and ends with "@ for double-quoted strings, or @' and '@ for single-quoted strings.
Click to reveal answer
beginner
How do you start and end a double-quoted here-string in PowerShell?
Start with @" on a new line and end with "@ on a new line. Everything between is part of the string, including line breaks.
Click to reveal answer
intermediate
What is the difference between single-quoted and double-quoted here-strings?
Double-quoted here-strings allow variable expansion and escape sequences. Single-quoted here-strings treat content literally, no variable expansion.
Click to reveal answer
beginner
Show a simple example of a here-string that contains multiple lines.
Example: $myString = @" Line one Line two Line three "@ This stores three lines in $myString.
Click to reveal answer
beginner
Why are here-strings useful in scripting?
They let you write long text blocks or scripts inside a variable without worrying about quotes or line breaks. This makes scripts easier to read and maintain.
Click to reveal answer
How do you start a double-quoted here-string in PowerShell?
A"@
B@"
C@'
D'@
Which here-string type allows variable expansion?
ADouble-quoted here-string
BSingle-quoted here-string
CBoth single and double-quoted here-strings
DNeither
What symbol ends a single-quoted here-string?
A'@
B@"
C"@
D@'
Which of these is a correct here-string assignment?
A$text = @" Hello World "@
B$text = @' Hello World '@
CBoth A and C
D$text = "Hello World"
Why use here-strings instead of normal strings for multiline text?
AHere-strings automatically trim spaces
BHere-strings do not support variables
CHere-strings are faster to execute
DHere-strings allow multiline text without escape characters
Explain how to create a multiline string using here-strings in PowerShell.
Think about how you open and close the string and what happens inside.
You got /4 concepts.
    Describe the difference between single-quoted and double-quoted here-strings and when you might use each.
    Consider how variables behave inside each type.
    You got /4 concepts.