Clay W
Clay W

Reputation: 13

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

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!

Upvotes: 1

Views: 10165

Answers (1)

Frode F.
Frode F.

Reputation: 54841

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

Upvotes: 1

Related Questions