Bird
0
0

What will this PowerShell code output?

medium📝 Command Output Q4 of 15
PowerShell - Variables and Data Types
What will this PowerShell code output?
$a = $true
$b = $false
if ($a -or $b) { "Yes" } else { "No" }
ANo
BFalse
CTrue
DYes
Step-by-Step Solution
Solution:
  1. Step 1: Understand the '-or' operator

    '-or' returns True if either side is True.
  2. Step 2: Evaluate the condition

    $a is $true, $b is $false, so '$a -or $b' is True, so the 'if' block runs and outputs 'Yes'.
  3. Final Answer:

    Yes -> Option D
  4. Quick Check:

    '-or' with one True = True [OK]
Quick Trick: '-or' returns true if any operand is true [OK]
Common Mistakes:
  • Thinking '-or' requires both True
  • Confusing output with Boolean literals
  • Ignoring the if-else structure

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes