Bird
0
0

Identify the error in this PowerShell statement:

medium📝 Debug Q6 of 15
PowerShell - Operators
Identify the error in this PowerShell statement:
if ($value -eq 10 -and) { 'Yes' }
AMissing parentheses around conditions
BTrailing '-and' without a second condition
CIncorrect use of '-eq' operator
DMissing 'else' block
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the conditional syntax

    The '-and' operator requires two conditions; here it is trailing without a second condition.
  2. Step 2: Identify syntax error

    This causes a syntax error because the expression is incomplete.
  3. Final Answer:

    Trailing '-and' without a second condition -> Option B
  4. Quick Check:

    '-and' needs two conditions [OK]
Quick Trick: Always provide two conditions with '-and' [OK]
Common Mistakes:
  • Leaving '-and' alone
  • Missing second condition
  • Assuming '-and' can stand alone

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes