Bird
0
0

Identify the error in this PowerShell snippet:

medium📝 Debug Q14 of 15
PowerShell - Variables and Data Types
Identify the error in this PowerShell snippet:
if ($True) { Write-Output "Yes" } else { Write-Output "No" }
ABoolean values must be lowercase: $true, $false
BMissing parentheses around condition
CWrite-Output is not valid in if blocks
DNo error, code runs fine
Step-by-Step Solution
Solution:
  1. Step 1: Check Boolean case sensitivity

    PowerShell Boolean values are case-insensitive, so $True works like $true.
  2. Step 2: Verify syntax correctness

    The if statement syntax is correct with parentheses and Write-Output is valid.
  3. Final Answer:

    No error, code runs fine -> Option D
  4. Quick Check:

    PowerShell Booleans are case-insensitive [OK]
Quick Trick: PowerShell Booleans ignore case [OK]
Common Mistakes:
  • Thinking $True is invalid case
  • Expecting syntax error without parentheses
  • Believing Write-Output can't be used here

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes