Bird
0
0

What will be the output of the following command?

medium📝 Command Output Q4 of 15
PowerShell - Cmdlets and Pipeline
What will be the output of the following command?
1..5 | Where-Object { $_ -lt 3 }
A3 4 5
B1 2 3
C1 2
DNo output
Step-by-Step Solution
Solution:
  1. Step 1: Understand the range and condition

    The range 1..5 produces numbers 1,2,3,4,5. The condition $_ -lt 3 means numbers less than 3.
  2. Step 2: Filter numbers less than 3

    Numbers less than 3 are 1 and 2 only.
  3. Final Answer:

    1 2 -> Option C
  4. Quick Check:

    Numbers less than 3 = 1 2 = B [OK]
Quick Trick: Use -lt for less than filtering in Where-Object [OK]
Common Mistakes:
  • Including 3 in output
  • Confusing -lt with -le
  • Expecting all numbers

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes