简体   繁体   English

在Powershell中获取CPU使用率的进程

[英]Get Process for CPU usage in powershell

This particular code in Powershell is to generate CPU usage (in percentage) same as the task manager. Powershell中的此特定代码用于生成与任务管理器相同的CPU使用率(百分比)。 But, the problem with this one is that it runs for once and for all not continuously. 但是,这一问题是它不能一劳永逸地运行。

Get-Process | Select-Object -Property Name, CPU, $CPUPercent, Description |Sort-Object -Property CPUPercent -Descending

How do I take the results continuously in mentioned time interval? 如何在上述时间间隔内连续获取结果?

Where is the mentioned time interval? 提到的时间间隔在哪里? You can take the results continuously using a do while loop: 您可以使用do while循环连续获取结果:

do
{
    Get-Process | Select-Object -Property Name, CPU, $CPUPercent, Description |Sort-Object -Property CPUPercent -Descending
    Sleep 1
}
while ($true)

Note : Im using the Sleep cmdlet to reduce the outputs. 注意 :Im使用Sleep cmdlet减少输出。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM