Bird
0
0

Identify the error in this PowerShell script:

medium📝 Debug Q14 of 15
PowerShell - String Operations
Identify the error in this PowerShell script:
$text = @'
Line 1
Line 2
"@
Write-Output $text
AThe here-string is not closed properly with '@
BUsing single quotes disables variable expansion
CThe ending delimiter "@ is incorrect for single-quoted here-string
DMissing Write-Output command
Step-by-Step Solution
Solution:
  1. Step 1: Check the here-string delimiters

    The here-string starts with @' (single-quoted) but ends with "@ (double-quoted), which is incorrect.
  2. Step 2: Correct delimiter matching

    Single-quoted here-strings must end with '@, matching the start delimiter.
  3. Final Answer:

    The ending delimiter "@ is incorrect for single-quoted here-string -> Option C
  4. Quick Check:

    Start and end delimiters must match [OK]
Quick Trick: Match start and end delimiters exactly for here-strings [OK]
Common Mistakes:
  • Mixing single and double quotes in delimiters
  • Forgetting to close the here-string
  • Assuming variable expansion error causes syntax error

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes