CPU usage of a process in real-time RRS feed

  • Question

  • How do I know the status of CPU usage of a process?
    I'm running this command and watching the task manager in real time, and not show the same data.

    $wmiClass ='Win32_PerfFormattedData_PerfProc_Process'
    Get-WmiObject $wmiClass -Filter{NOT (NAME = "Idle" OR NAME = "_Total")} |
    select  Name,PercentProcessorTime,IDProcess | where {$ -eq 'XXXXX'}

    • Moved by Bill_Stewart Monday, May 2, 2016 5:40 PM Help vampire "question"
    Sunday, February 28, 2016 6:53 PM

All replies

  • Not really a scripting question.  First start by looking up what the performance counters are and what they do.  Realize that WMI and Task Manager are not reporting the same data so they will never match.

    Run this and think about what you see:

    	Get-WmiObject Win32_PerfFormattedData_PerfProc_Process -filter 'PercentProcessorTime > 0 AND IdProcess >0' |
    	select name,PercentProcessorTime
    	write-host 'scan --------------->'
    	sleep 1


    Sunday, February 28, 2016 7:25 PM