Search code examples
powershellpowershell-2.0powershell-3.0

How to get Total CPU usage percentage without instance name in powershell


Get-WmiObject Win32_Processor | Measure-Object -Property LoadPercentage -Average | Select Average
I will get output like

Average
-----------
30
how can i get that value 30 only .


Solution

  • To get just the value, ccess the Average propert of Measure-Object's output. No need to pipe the results to Select-Object at all. Like so,

    (Get-WmiObject Win32_Processor | Measure-Object -Property LoadPercentage -Average).Average
    8