Bird
0
0

Why does this command fail?

medium📝 Debug Q7 of 15
PowerShell - Cmdlets and Pipeline
Why does this command fail?
Get-Service | Select-Object -Property Name, Status, | Where-Object { $_.Status -eq 'Running' }
AWhere-Object cannot filter after Select-Object
BGet-Service does not output objects with Status
CName is not a valid property
DTrailing comma after 'Status' causes syntax error
Step-by-Step Solution
Solution:
  1. Step 1: Inspect Select-Object property list

    Trailing comma after 'Status' is invalid syntax causing error.
  2. Step 2: Verify other parts

    Where-Object can filter after Select-Object; Name and Status are valid properties.
  3. Final Answer:

    Trailing comma after 'Status' causes syntax error -> Option D
  4. Quick Check:

    Remove trailing commas in property lists [OK]
Quick Trick: No trailing commas in property lists [OK]
Common Mistakes:
  • Leaving trailing commas in arrays or lists
  • Assuming Where-Object can't follow Select-Object
  • Misnaming properties

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes