question

MikhailFirsov-1277 avatar image
0 Votes"
MikhailFirsov-1277 asked ·

Using Performance Monitor counter IDs instead of the counter names - 2

Hello,

As you already may know each Performance Monitor counter has the corresponding ID which you can find in the registry:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Perflib\009\Counter

So theoretically we can get the counter value by typing

Get-Counter -Counter "\2\10" instead of

Get-Counter -Counter "\System\File Read Operations/sec" - and it does work:
61443-1.png

But I don't understand why other counters may not be read by such method:

Get-Counter -Counter "\System\File Read Operations/sec"
61374-2.png

What's wrong with the second query?

Here's one more example:
61383-3.png

Thank you in advance,
Michael


windows-serverwindows-server-powershellwindows-server-2019windows-server-2016
1.png (18.6 KiB)
2.png (23.1 KiB)
3.png (40.0 KiB)
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

IanXue-MSFT avatar image
0 Votes"
IanXue-MSFT answered ·

Hi,

According to the help documentation, the -counter parameter uses counter names, not IDs. It doesn't seem to support IDs well. The following link gives a way to get local counter names from IDs
https://www.powershellmagazine.com/2013/07/19/querying-performance-counters-from-powershell/

Best Regards,
Ian Xue
============================================
If the Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

MikhailFirsov-1277 avatar image
0 Votes"
MikhailFirsov-1277 answered ·

Hi IanXue-MSFT,

Sorry for the delay. Thank you for yor help!

It's really weird that some of the IDs do really work in the Get-Counter. In computers some feature usually either works or does not work, but not 50/50...

Regards,
Michael

·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.