I am very new to Powershell. I need to get Page Faults and Disk IO of system while a particular process is running. I am able to get Page Faults but not able to get Disk IO. Can u guys help me please. Below is my code:

 $arrayDIO = @()
 $arrayPf = @()
 $cmdProcess = start-process cmd -passthru
   while (-not $cmdProcess.HasExited) {
        $arrayDIO += %{ (Get-WmiObject Win32_PerfFormattedData_PerfProc_Process).IOWriteOperationsPerSec }
        $arrayPf += %{ (Get-WmiObject Win32_PerfFormattedData_PerfOS_memory).PageFaultsPerSec }
    sleep 2
 $arrayPf | Measure-Object -Average -Maximum -Minimum | Out-File  -Filepath C:\Details.txt
 $arrayDIO | Measure-Object -Average -Maximum -Minimum | Out-File  -Filepath C:\Details.txt -append
  • This is not a disk IO performance counter, by the way. It's a counter for process write operations (a quantity measured not in volume of data). Maybe pedantic, but do you mind if I update the Q?
    – john
    Jul 25, 2013 at 21:01

1 Answer 1


You are grabbing a performance counter that returns the process data for each individual process, plus all processes combined into one counter (_Total). You'll need to filter by the process name to get that specific process's performance data.

The reason you have no data is because the Get-WMIObject command returns an array of ManagementBaseObject objects, each containing the attribute IOWriteOperationsPersec but the array doesn't contain that attribute itself. You end up with an empty $arrayDIO array and therefore no performance data for Measure-Object.

See the updated code in line 5 from your example:

$arrayDIO += % { (Get-WmiObject Win32_PerfFormattedData_PerfProc_Process | Where-Object { $_.Name -eq "_Total"}).IOWriteOperationsPersec }

Where I have put "_Total" you can replace this with the actual process name you want to get the counter data for, or just leave it as-is to retrieve the total for all processes.


To make this work on Physical Disk Writes, you need to use a different performance counter (http://msdn.microsoft.com/en-us/library/windows/desktop/aa394308(v=vs.85).aspx).

Give this a try:

$arrayDIO += % { (Get-WmiObject Win32_PerfRawData_PerfDisk_PhysicalDisk | Where-Object { $_.Name -like "0*"}).DiskWriteBytesPersec /1024 }

/1024 converts the counter from Bytes to MB and "0*" selects the disk id. If you have multiple disks, you'll need to change this to the correct disk ID.

  • Thank u very much for the answer... I have to get Disk IO (MB/sec) and calculate the Average and Maximum... Does the above code you provided do the same? Please help me...
    – Avadhani Y
    Jul 26, 2013 at 6:07
  • @AvadhaniY Do you want Logical Disk or Physical Disk? Physical disk will give you the total IO for a physical disk (the physical hardware). Logical Disk will will give IO for volumes (partitions).
    – john
    Jul 26, 2013 at 7:19
  • I want for a Physical Disk IO...
    – Avadhani Y
    Jul 26, 2013 at 7:22
  • @AvadhaniY I have updated my answer. I hope it works for you.
    – john
    Jul 26, 2013 at 7:48
  • Thanks for the updated answer.. but i am not getting any output for the latest code line... FYI, i ahve only one Physical disk in my system...
    – Avadhani Y
    Jul 26, 2013 at 8:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.