Bird
0
0

Identify the error in this pipeline command:

medium📝 Debug Q14 of 15
PowerShell - Cmdlets and Pipeline
Identify the error in this pipeline command:
Get-Service | Where-Object Status -eq 'Running' | Select Name
ASelect should be Select-Object, not Select.
BGet-Service cannot be piped to Where-Object.
CThe comparison operator should be inside the script block {} in Where-Object.
DThe pipeline operator is missing.
Step-by-Step Solution
Solution:
  1. Step 1: Check Where-Object syntax

    The condition must be inside a script block: { $_.Status -eq 'Running' }. The given command misses the braces.
  2. Step 2: Verify other parts

    Select is an alias for Select-Object, so it's valid. Get-Service can be piped. Pipeline operator is present.
  3. Final Answer:

    The comparison operator should be inside the script block {} in Where-Object. -> Option C
  4. Quick Check:

    Where-Object needs script block for conditions [OK]
Quick Trick: Put conditions inside {} for Where-Object [OK]
Common Mistakes:
  • Omitting braces {} in Where-Object
  • Thinking Select is invalid
  • Assuming pipeline operator is missing

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes