How to get I/O read and write bytes for process or drive with PowerShell

Karolo 26 Reputation points
2021-06-04T18:13:22.29+00:00

Would like to view:

  • For a process, how many bytes are read and written to drive(s).
  • For a drive (D:, E:, etc.), same thing, how many bytes are read and written to on a period of time (all processes). Start counting at specific time and end at specific time, and display values in-between.

The Windows 10 Task Manager (C:\Windows\System32\Taskmgr.exe) has the ability, on Details tab, to display "I/O read bytes" and "I/O write bytes" for each process. Would like to get this information on a terminal to save directly those values to text files.
Maybe I need some additional software besides PowerShell.

Windows for business | Windows Server | User experience | PowerShell
0 comments No comments
{count} votes

Accepted answer
  1. Anonymous
    2021-06-05T03:28:59.743+00:00

    Hi,

    You can use the Win32_Process WMI class to get them.

    Get-WmiObject -Class Win32_Process -Filter {Name = 'MyProcess.exe'}| Select-Object Name,ReadTransferCount,WriteTransferCount  
    

    Best Regards,
    Ian Xue

    ============================================

    If the Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


5 additional answers

Sort by: Most helpful
  1. Karolo 26 Reputation points
    2021-06-04T21:38:07.897+00:00

    How to I get the bytes read and written for MyProcess.exe? Not per second, total, since the program has started. Like Task Manager shows.

    1 person found this answer helpful.
    0 comments No comments

  2. Rich Matheisen 47,901 Reputation points
    2021-06-04T18:23:36.027+00:00

    You'll have to get that information from performance monitor (just as TaskMgr does). Use the Get-Counter cmdlet for that.

    0 comments No comments

  3. Karolo 26 Reputation points
    2021-06-04T20:47:50.78+00:00

    Any specific command please?

    0 comments No comments

  4. Rich Matheisen 47,901 Reputation points
    2021-06-04T21:11:57.47+00:00

    Specific command? Get-Counter. Look for that cmdlet name in a search engine. You'll find numerous examples.

    An example:

    $gc = get-counter '\Process(*)\IO Read Bytes/sec'
    $gc | Sort-Object cookedvalue
    
    $gc.gettype()
    
    
    IsPublic IsSerial Name                                     BaseType
    -------- -------- ----                                     --------
    True     False    PerformanceCounterSampleSet              System.Object
    
    $gc.CounterSamples[0]
    
    
    Path                                   InstanceName CookedValue
    ----                                   ------------ -----------
    \\ws06\process(idle)\io read bytes/sec idle                   0
    
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.