PowerTip: Use PowerShell to Find Total CPU Time

Summary: Use Windows PowerShell to find the total CPU time of a process.

Hey, Scripting Guy! Question How can I return a timespan that represents the total CPU time of a process?

Hey, Scripting Guy! Answer Use the Get-Process cmdlet and select the TotalProcessorTime property:

PS C:\> (gps excel).totalprocessortime


Days              : 0

Hours             : 0

Minutes           : 0

Seconds           : 4

Milliseconds      : 524

Ticks             : 45240290

TotalDays         : 5.23614467592593E-05

TotalHours        : 0.00125667472222222

TotalMinutes      : 0.0754004833333333

TotalSeconds      : 4.524029

TotalMilliseconds : 4524.029 

Comments (3)

  1. John says:


    Love these new powertips. They are great learning tools that allows me to incorporate them in my scripts that I am writing. Thank you very much.

  2. Ed Wilson says:

    @John I am glad you love the new PowerTips. I was not certain how well they would do when I first started writing them. I now have several months worth of PowerTips, and they have their own tags. You can see only the PowerTips here:  blogs.technet.com/…/powertip

  3. Itsme2033 says:

    When I do this for my local system it returns all the properties as expected. When I do it for a remote system I get values for some properties and not for others for example, if I do:

    (Get-Process -ComputerName MyServer -name sqlservr).Handles then I get a number that corresponds to the handles as shown in task manager on the remote system.

    If I give the following command:
    (Get-Process -ComputerName MyServer -name sqlservr).TotalProcessorTime
    then the result is always blank.

    Is this the expected behavior? Is there something else that I need to give to this command to make it work, or do I need to use another command?

Skip to main content