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

Mikhail Firsov 1,876 Reputation points
2021-01-28T09:30:45.383+00:00

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 Server 2019
Windows Server 2019
A Microsoft server operating system that supports enterprise-level management updated to data storage.
3,442 questions
Windows Server 2016
Windows Server 2016
A Microsoft server operating system that supports enterprise-level management updated to data storage.
2,368 questions
Windows Server
Windows Server
A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.
12,076 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,353 questions
0 comments No comments
{count} votes

Accepted answer
  1. Ian Xue (Shanghai Wicresoft Co., Ltd.) 29,476 Reputation points Microsoft Vendor
    2021-02-01T06:27:58.537+00:00

    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.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Mikhail Firsov 1,876 Reputation points
    2021-02-08T09:11:34.26+00:00

    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

    0 comments No comments