Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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 '14 at 16:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .