Bird
0
0

Which of the following is a valid Boolean expression in PowerShell?

easy📝 Conceptual Q1 of 15
PowerShell - Variables and Data Types
Which of the following is a valid Boolean expression in PowerShell?
Atrue == false
B$true = $false
C$true -eq $false
DTrue = False
Step-by-Step Solution
Solution:
  1. Step 1: Understand PowerShell Boolean comparison syntax

    PowerShell uses '-eq' to compare values, not '=' or '==' which are invalid for comparison.
  2. Step 2: Evaluate each option

    $true -eq $false uses '$true -eq $false' which is valid and returns False. Options B, C, and D use invalid syntax for comparison.
  3. Final Answer:

    $true -eq $false -> Option C
  4. Quick Check:

    Boolean comparison uses '-eq' = A [OK]
Quick Trick: Use '-eq' for equality checks in PowerShell [OK]
Common Mistakes:
  • Using '=' instead of '-eq' for comparison
  • Using '==' which is not valid in PowerShell
  • Confusing assignment with comparison

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes