Bird
0
0

What will be the output of this command?

medium📝 Command Output Q4 of 15
PowerShell - Cmdlets and Pipeline
What will be the output of this command?
Get-Process | Where-Object { $_.Handles -gt 500 } | Select-Object -First 2 -Property Name, Handles
AAll processes with more than 500 handles, showing only their Name
BThe first two processes with more than 500 handles, showing their Name and Handles
CAn error because Select-Object cannot be used after Where-Object
DThe first two processes regardless of handle count
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the pipeline commands

    Get-Process gets all processes, Where-Object filters those with Handles > 500, and Select-Object picks the first two and selects Name and Handles properties.
  2. Step 2: Determine output

    The output will be two process objects with Handles > 500, showing only Name and Handles.
  3. Final Answer:

    The first two processes with more than 500 handles, showing their Name and Handles -> Option B
  4. Quick Check:

    Pipeline filters then selects first two = The first two processes with more than 500 handles, showing their Name and Handles [OK]
Quick Trick: Where-Object filters, Select-Object picks properties and count [OK]
Common Mistakes:
  • Thinking Select-Object cannot follow Where-Object
  • Assuming all processes are shown
  • Ignoring the -First parameter

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes