在powershell中按CPU使用百分比列出进程 [英] Listing processes by CPU usage percentage in powershell
本文介绍了在powershell中按CPU使用百分比列出进程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何通过将 Get-Process
的输出传送到 Where-Object
来列出使用 CPU > 1% 的进程?
How does one lists the processes using CPU > 1% by piping the output from Get-Process
to Where-Object
?
我能想到的完全是powershell的初学者
Complete beginner to powershell all i can think is something like this
Get-Process | Where-Object { CPU_Usage -gt 1% }
推荐答案
如果你想要 CPU 百分比,你可以使用 Get-Counter 来获取性能计数器,Get-Counter 可以为所有进程运行.因此,要列出 CPU 使用率超过 5% 的进程:
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}
这将列出在采样实例中使用超过 5% CPU 的进程.希望这会有所帮助!
This will list the processes that was using >5% of CPU at the instance the sample was taken. Hope this helps!
这篇关于在powershell中按CPU使用百分比列出进程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文