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:
$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
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'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With