Bird
0
0

What is the output of this command?

medium📝 Command Output Q5 of 15
PowerShell - Cmdlets and Pipeline
What is the output of this command?
1..5 | ForEach-Object { $_ * 2 } | Where-Object { $_ -gt 6 }
A8, 10
BNo output
C2, 4, 6, 8, 10
D7, 8, 9, 10
Step-by-Step Solution
Solution:
  1. Step 1: Evaluate ForEach-Object output

    Numbers 1 to 5 are multiplied by 2, resulting in 2, 4, 6, 8, 10.
  2. Step 2: Apply Where-Object filter

    Filter keeps numbers greater than 6, so 8 and 10 remain.
  3. Final Answer:

    8, 10 -> Option A
  4. Quick Check:

    Multiply then filter >6 = 8 and 10 [OK]
Quick Trick: Pipeline processes each object step-by-step [OK]
Common Mistakes:
  • Including numbers less than or equal to 6
  • Misunderstanding ForEach-Object output
  • Assuming output is a string

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes