如何使用Powershell命令确定平均CPU百分比并以无标签的数字百分比形式输出CPU百分比 [英] How to Determine the Average CPU Percentage using a Powershell Command and Output the CPU Percentage as a Numeric Percentage with no Labels
本文介绍了如何使用Powershell命令确定平均CPU百分比并以无标签的数字百分比形式输出CPU百分比的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在努力获得一个powershell命令,该命令使我可以将远程服务器的所有核心上的平均cpu百分比拉出,并将该值输出为数字百分比。我很接近,但一直无法找到一种方法来获取数值。以下是我正在使用的命令,然后是输出。
I'm am working to get a powershell command that allows me to pull the average cpu percentage over all the cores for a remote server, and output the value as just the numeric percentage. I am Close but have not been able find a way to just get the Numeric value. The Following is the command I am using followed by the output.
Get-WmiObject -computer server -class win32_processor | Measure-Object -property LoadPercentage -Average | FL average
Average : 30.5
在此先感谢任何帮助!
推荐答案
尝试选择对象
的 ExpandProperty
参数以获取属性的值。更新的脚本:
Try Select-Object
's ExpandProperty
parameter to get the value of a property. Updated script:
Get-WmiObject -computer server -class win32_processor | Measure-Object -property LoadPercentage -Average | Select-Object -ExpandProperty Average
这篇关于如何使用Powershell命令确定平均CPU百分比并以无标签的数字百分比形式输出CPU百分比的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文