Bird
0
0

You want to store a multiline string that includes variable names literally (no expansion) and special characters like $ and ` in PowerShell. Which here-string style should you use?

hard📝 Application Q8 of 15
PowerShell - String Operations
You want to store a multiline string that includes variable names literally (no expansion) and special characters like $ and ` in PowerShell. Which here-string style should you use?
ASingle-quoted here-string (@' ... '@)
BDouble-quoted here-string (@" ... "@)
CRegular double quotes with backticks
DRegular single quotes with backticks
Step-by-Step Solution
Solution:
  1. Step 1: Understand variable expansion in here-strings

    Double-quoted here-strings expand variables and special characters, single-quoted do not.
  2. Step 2: Choose style to keep variables and special chars literal

    Single-quoted here-strings preserve text exactly, including $ and backticks, without expansion.
  3. Final Answer:

    Single-quoted here-string (@' ... '@) -> Option A
  4. Quick Check:

    Literal text with no expansion = single-quoted here-string = Single-quoted here-string (@' ... '@) [OK]
Quick Trick: Use single-quoted here-strings to keep text literal [OK]
Common Mistakes:
  • Using double-quoted here-strings expecting no expansion
  • Trying to escape variables inside double-quoted here-strings
  • Confusing regular quotes with here-strings

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes