Question:
I need to get Page Faults and Disk IO of system while a particular process is running.
I can get Page Faults but not able to get Disk IO:
1 2 3 4 5 6 7 8 9 10 11 |
$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 |
Answer:
Rather than Get-WMIObject, use the built-in command for getting performance data, Get-Counter:
Get-Counter '\Process(*)\IO Data Operations/sec'
Get-Counter '\Memory\Page Faults/sec'