开发者

Sending a Refresh() to WMI in PowerShell

开发者 https://www.devze.com 2022-12-22 01:10 出处:网络
In a PowerShell script I am trying to get the number of page faults per second with this command: (Get-WmiObject Win32_PerfFormattedData_PerfOS_memory).PageFaultsPersec

In a PowerShell script I am trying to get the number of page faults per second with this command:

(Get-WmiObject Win32_PerfFormattedData_PerfOS_memory).PageFaultsPersec

Unfortunately, it reads always the same value because I do开发者_如何学JAVAn't Refresh() the performance counter.

How can I send a Refresh() method to Performance Data via PowerShell?


You can get the value using performance counters:

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

However, if I call you code in a loop, it works without problems (although it is better practise to first store the wmi object).

1..10 | % { sleep -sec 2; (Get-WmiObject Win32_PerfFormattedData_PerfOS_memory).PageFaultsPersec }
0

精彩评论

暂无评论...
验证码 换一张
取 消