powershell - 使用 PowerShell 获取 CPU 百分比

标签 powershell cpu monitoring

我正在尝试按百分比获取 CPU 使用率。 我看到了两个选项,但它们都不适合我,它们都给了我一个数字,根据任务管理器的说法,这是不正确的。

这是我尝试过的两个命令:

  1. 获取 WmiObject Win32_Processor |选择负载百分比 |格式列表

  2. 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
    

感谢您的帮助!

最佳答案

尝试取其平均值。这是link .

Get-CimInstance -ClassName win32_processor | Measure-Object -Property LoadPercentage -Average

关于powershell - 使用 PowerShell 获取 CPU 百分比,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71457671/

相关文章:

powershell - Powershell:从日志文件中提取数据以创建新对象

ios - 当我运行 for-in 循环时 CPU 使用率飙升 : OS-x app

linux - 在 Linux 上查找内核是 32 位还是 64 位

.net - 到 PerformanceCounter 还是编写自定义监控?

linux - 实时监控工具 Cisco(RTMT) 和 Postfix

python - 分布式微服务监控工具

Powershell 5.1.16299.1146 Get-ADGroupMember 出现操作错误

powershell - 使用参数从 Powershell 脚本运行可执行文件

excel - 如何使用 PowerShell 将 VBA 代码添加到 Excel 工作表?

x86 - x86 cpu有什么样的地址指令?