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

StackOverflow https://stackoverflow.com/questions/21706117

  •  10-10-2022
  •  | 
  •  

Question

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!

Était-ce utile?

La solution

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
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top