如何使用 PowerShell 獲取程序效能計數器?


要獲取所有與程序相關的計數器,你需要使用以下命令。

示例

Get-Counter -ListSet "*Processor*" | Select CounterSetName

輸出

CounterSetName
--------------
Processor Information
Per Processor Network Activity Cycles
Per Processor Network Interface Card Activity
Hyper-V Worker Virtual Processor
Hyper-V Hypervisor Virtual Processor
Hyper-V Hypervisor Root Virtual Processor
Hyper-V Hypervisor Logical Processor
Processor
Processor Performance

現在假設我們需要處理器效能計數器集,那麼我們可以使用以下命令來檢索其所有計數器。

PS C:\> Get-Counter -ListSet "Processor Performance" | Select -ExpandProperty Counter
\Processor Performance(*)\Processor Frequency
\Processor Performance(*)\% of Maximum Frequency
\Processor Performance(*)\Processor State Flags

假設我們需要其中的處理器最大頻率計數器,然後,

示例

Get-Counter -Counter '\Processor Performance(*)\% of Maximum Frequency'

輸出

要連續執行效能計數器,請使用,

示例

Get-Counter -Counter '\Processor Performance(*)\% of Maximum Frequency' -Continuous

要檢索特定時間間隔的特定數量的樣本,

示例

Get-Counter -Counter '\Processor Performance(*)\% of Maximum Frequency' -SampleInterval 2 -MaxSamples 3

更新日期: 2021 年 4 月 12 日

400 人瀏覽

開啟您的 職業生涯

完成課程即可獲得認證

開始
廣告