question

Karolo avatar image
0 Votes"
Karolo asked Karolo commented

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

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-server-powershell
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

IanXue-MSFT avatar image
0 Votes"
IanXue-MSFT answered Karolo commented

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.

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thank you very much that worked wonderfully!!!!!!!

0 Votes 0 ·
RichMatheisen-8856 avatar image
0 Votes"
RichMatheisen-8856 answered

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

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Karolo avatar image
0 Votes"
Karolo answered

Any specific command please?

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

RichMatheisen-8856 avatar image
0 Votes"
RichMatheisen-8856 answered

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


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Karolo avatar image
0 Votes"
Karolo answered

Your example gets "bytes/sec". I want I/O read and write bytes.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Karolo avatar image
1 Vote"
Karolo answered Karolo edited

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.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.