Bird
0
0

What will be the output of this PowerShell code?

medium📝 Command Output Q4 of 15
PowerShell - String Operations
What will be the output of this PowerShell code?
$text = @'
Line1
Line2
Line3
'@
Write-Output $text
A3eniL 2eniL 1eniL
Bine1 Line2 Line3
CLine1 Line2 Line3
DLine1 Line2 Line3
Step-by-Step Solution
Solution:
  1. Step 1: Understand single-quoted here-string behavior

    Single-quoted here-strings preserve all newlines and text exactly as typed without any expansion.
  2. Step 2: Analyze the output of Write-Output

    The here-string structure includes newlines after Line1, Line2, Line3, and a trailing newline before the closing delimiter, so the output is Line1 Line2 Line3 .
  3. Final Answer:

    Line1 Line2 Line3 -> Option D
  4. Quick Check:

    Single-quoted here-string multiline output = Line1 Line2 Line3 [OK]
Quick Trick: Single-quoted here-strings preserve newlines exactly [OK]
Common Mistakes:
  • Forgetting the trailing newline before closing delimiter
  • Thinking output collapses to single line
  • Confusing with double-quoted here-string behavior

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes