locked
Get-Process CPU(s) - Converts CPU in seconds to total CPU percentage RRS feed

  • Question

  • The Get-Process cmdlet gives the processes information, with CPU usage in Seconds, How to convert seconds to percentage

    PS C:\Users\7878702> Get-Process

    Handles  NPM(K)    PM(K)      WS(K)         CPU(s)     Id  SI ProcessName
    -------  ------    -----      -----     ------     --  -- -----------
        858      47    80608      75200             20164   0 AdaptivaClientService
        158       9     1880       7436              6808   0 aesm_service
        267      34    19888      19156       1.48  13676   1 AMI.Scanner.Client
        351      22    11284      31684       2.77   3820   1 ApplicationFrameHost
        190       9     6712       6580       0.67   1872   1 bash
        112       7     1732       5476       0.80  12532   1 brkrprcs64
        509      28    16472      39276       0.41   5544   1 Calculator
        266      18    78440      43420              4220   0 cb
       1540      47    27684      57040              7824   0 CcmExec
        299      29    68896      82972      55.84    540   1 chrome
        357      41   111992     107496      72.58   1436   1 chrome
        278      26    39324      29532       1.73   1680   1 chrome
        397      31    45032      81572      13.09   1732   1 chrome
        160      13     2656      11872       0.50   1832   1 chrome
        303      45    74248     106508      32.72   2040   1 chrome
        296      29    56984      59008      10.19   3192   1 chrome
        304      29    53316      41480       4.95   3408   1 chrome
        343      45   107364      62236      75.78   3612   1 chrome
        331      36   100000      85320      61.53   3648   1 chrome

    Here I need two things

    1. How to convert total CPU usage which is in seconds  in to percentage..? Say 55% consumed.
    2. Get the top 5 Process which consume CPU the most..?

    Wednesday, February 6, 2019 11:46 AM

All replies

  • Hi Sijo,

    First you might want to ask this type of question in the scripting part of the forums, you'll get more response there.

    As to your request, the Get-Process command also has a CPU % value, but by default it does not return it.

    If my interpretation of your question is correct, the following should return the top 5 CPU heavy processes and also show you the % of CPU they use at that point:

    Get-Process | select -Property Name, CPU -First 5 | sort -Property CPU -Descending


    Please remember to mark the post(s), which answered your question.

    Wednesday, February 6, 2019 2:14 PM
  • Thanks Thomas G333 but, 

    With the below command

    Get-Process | select -Property Name, CPU -First 5 | sort -Property CPU -Descending

    Still I get CPU usage in seconds.. not in percentage.

    My requirement here is to, 

    Using Command-lets Get Total CPU usage in percentage at any given point in time, plus the top 5 process which consumes most CPUs, 

    I know from a UI perspective TaskManager OR Resourcemonitor provides the same information, but I need this information using commandlets. 

    Thursday, February 7, 2019 4:50 AM