Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I want to get the value that is shown in task manager for any process in the CPU column in powershell.

I tried using

Get-Process ProcessName | Select-Object -Property CPU

but it only returns the time spent.

share|improve this question

1 Answer 1

Try using the Get-Counter command which pulls the data from the system's performance monitor. For your example, it would look like this:

# ~> Get-Counter "\Process(ProcessName*)\% Processor Time" | select -expand countersamples 

An example, using chrome:

# ~> Get-Counter "\Process(chrome*)\% Processor Time" | select -expand countersamples 

Path                                            InstanceName      CookedValue
----                                            ------------      -----------
\\machinename\process(chrome#7)\% processor time chrome                      0
\\machinename\process(chrome#6)\% processor time chrome                      0
\\machinename\process(chrome#5)\% processor time chrome                      0
\\machinename\process(chrome#4)\% processor time chrome                      0
\\machinename\process(chrome#3)\% processor time chrome                      0
\\machinename\process(chrome#2)\% processor time chrome                      0
\\machinename\process(chrome#1)\% processor time chrome                      0
\\machinename\process(chrome)\% processor time   chrome       3.10141153081511
share|improve this answer
    
Thanks for the post but I got it working by the code : get-wmiobject Win32_PerfFormattedData_PerfProc_Process| Select-Object -Property Name, PercentProcessorTime –  Akshay Patil Apr 8 at 16:54

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.