[英]getting CPU percentage with PowerShell
I am trying to get the CPU usage by percent.我正在尝试按百分比获取 CPU 使用率。 I saw 2 option around but non of them work for my, both of them gave me a num that according to the task manager is not correct.
我看到周围有 2 个选项,但没有一个适合我,他们都给了我一个根据任务管理器不正确的数字。
this is the two command that I tried:这是我试过的两个命令:
Get-WmiObject Win32_Processor | Select LoadPercentage | Format-List
Get-Counter -ComputerName localhost '\Process(*)\% Processor Time' ` | Select-Object -ExpandProperty countersamples ` | Select-Object -Property instancename, cookedvalue ` | Sort-Object -Property cookedvalue -Descending | Select-Object -First 20 ` | ft InstanceName,@{L='CPU';E={($_.Cookedvalue/100).toString('P')}} -AutoSize
thanks for your help!感谢您的帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.