Bird
0
0

You want to list all running services, then output only their names in uppercase using the pipeline. Which command achieves this?

hard📝 Application Q8 of 15
PowerShell - Cmdlets and Pipeline
You want to list all running services, then output only their names in uppercase using the pipeline. Which command achieves this?
AGet-Service | Select-Object Name | Where-Object { $_.Status -eq 'Running' }
BGet-Service | ForEach-Object { $_.Name.ToUpper() } | Where-Object { $_.Status -eq 'Running' }
CGet-Service | Where-Object { $_.Status -eq 'Running' } | Select-Object Name.ToUpper()
DGet-Service | Where-Object { $_.Status -eq 'Running' } | ForEach-Object { $_.Name.ToUpper() }
Step-by-Step Solution
Solution:
  1. Step 1: Filter running services first

    Use Where-Object to select services with Status 'Running'.
  2. Step 2: Convert names to uppercase

    Use ForEach-Object to transform each service's Name property to uppercase.
  3. Final Answer:

    Get-Service | Where-Object { $_.Status -eq 'Running' } | ForEach-Object { $_.Name.ToUpper() } -> Option D
  4. Quick Check:

    Filter then transform names to uppercase = Get-Service | Where-Object { $_.Status -eq 'Running' } | ForEach-Object { $_.Name.ToUpper() } [OK]
Quick Trick: Filter before transforming objects in pipeline [OK]
Common Mistakes:
  • Transforming before filtering
  • Using Select-Object incorrectly for method calls
  • Filtering after selecting only Name

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes