How to Determine the Average CPU Percentage using a Powershell Command and Output the CPU Percentage as a Numeric Percentage with no Labels

巧了我就是萌 提交于 2019-12-23 04:24:46

问题


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

Thanks in advance for any Help!


回答1:


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


来源:https://stackoverflow.com/questions/21706117/how-to-determine-the-average-cpu-percentage-using-a-powershell-command-and-outpu

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!