Bird
0
0

You want to write a script that lists all running processes with total CPU time over 5 seconds in PowerShell and save only their names to a text file. Which command sequence correctly achieves this?

hard📝 Application Q8 of 15
PowerShell - Basics and Environment
You want to write a script that lists all running processes with total CPU time over 5 seconds in PowerShell and save only their names to a text file. Which command sequence correctly achieves this?
AGet-Process | Where-Object { $_.CPU -gt 5 } | Select-Object -ExpandProperty Name > processes.txt
Bps | grep CPU>5 | cut -d ' ' -f1 > processes.txt
CGet-Process | Where CPU > 5 | Out-File processes.txt
Dtasklist | findstr CPU>5 > processes.txt
Step-by-Step Solution
Solution:
  1. Step 1: Filter processes by total CPU time in PowerShell

    Use Get-Process piped to Where-Object with condition { $_.CPU -gt 5 }.
  2. Step 2: Extract process names and save to file

    Select-Object -ExpandProperty Name outputs names only; redirect with > to save.
  3. Final Answer:

    Get-Process | Where-Object { $_.CPU -gt 5 } | Select-Object -ExpandProperty Name > processes.txt -> Option A
  4. Quick Check:

    Correct PowerShell filtering and output redirection = Get-Process | Where-Object { $_.CPU -gt 5 } | Select-Object -ExpandProperty Name > processes.txt [OK]
Quick Trick: Use Select-Object -ExpandProperty Name to get names only [OK]
Common Mistakes:
  • Using Bash commands in PowerShell
  • Missing script block braces
  • Not extracting names properly

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes