check powershell process cpu usage


I try to check cpu usage by prowershell process, the following query returns 0%, why ?

  $ProcessList = gwmi Win32_PerfFormattedData_PerfProc_Process -Filter "name like 'PowerShell%'"  | where {$_.Name -ne "_Total" -and $_.Name -ne "Idle"} | select IDProcess,Name,PercentProcessorTime | sort PercentProcessorTime -Descending
  $PS_CPU = ($ProcessList | Measure-Object -Property PercentProcessorTime -Sum).Sum 
  echo $PS_CPU

Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Phil DavidsonCommented:
By prowershell process?  Surely you mean PowerShell.

The PowerShell commands operate on processes named "PowerShell" or have "PowerShell" in their name.  Unless you have some job running with PowerShell, it may using nothing more than a negligible amount of CPU.  I just tried a portion of the query above, I found the same thing you found.  My Task Manager also confirmed that PowerShell, while open, was using 0% of the CPU.

To answer the question, because it uses very little CPU unless you have a heavy command running (e.g., in a separate window).

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
bibi92Author Commented:
The PowerShell commands operate on processes named "PowerShell" . Thanks regards
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.