Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Listing processes by CPU usage percentage in powershell

Tags:

powershell

How does one lists the processes using CPU > 1% by piping the output from Get-Process to Where-Object?

Complete beginner to powershell all i can think is something like this

Get-Process | Where-Object { CPU_Usage -gt 1% }
like image 671
Ulug Toprak Avatar asked Oct 09 '16 13:10

Ulug Toprak


People also ask

How do I get CPU utilization percentage in PowerShell?

Use the counter '\Process(*)\% Processor Time' with Get-Counter in PowerShell. The most valuable data from this is "cookedvalue," which is the readable view of the data. In this case, the data displays as a percentage.

How do I get CPU information in PowerShell?

In the Run window, type: dxdiag (without quotation marks). In the DirectX Diagnostic Tool window, in the System tab, general information about the computer processor will be displayed.


1 Answers

If you want CPU percentage, you can use Get-Counter to get the performance counter and Get-Counter can be run for all processes. So, to list processes that use greater than say 5% of CPU use:

(Get-Counter '\Process(*)\% Processor Time').CounterSamples | Where-Object {$_.CookedValue -gt 5}

This will list the processes that was using >5% of CPU at the instance the sample was taken. Hope this helps!

like image 139
sunilvijendra Avatar answered Oct 20 '22 13:10

sunilvijendra