4

我需要在特定进程运行时获取系统的页面错误和磁盘 IO。

我可以获得页面错误但无法获得磁盘 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
4

1 回答 1

8

而不是Get-WMIObject,使用内置命令获取性能数据Get-Counter

Get-Counter '\Process(*)\IO Data Operations/sec'

Get-Counter '\Memory\Page Faults/sec'

于 2013-07-25T12:47:29.060 回答