Use PowerShell to list all Windows Performance Counters and their numeric IDs

I’ve been looking into using Zabbix again lately, and was delighted to see that they’ve now released a refreshed and improved version 3.0

Whilst I was browsing some of my old Chrome bookmarks for Zabbix, I came across their article about Windows performance counters. They mention that performance counters in Windows have localised names, and that if you’re running systems in several different languages, you need to refer to the counters by their ID, rather than by name, when configuring monitoring.

This can be achieved by looking the list up in the registry, but it’s all just stored as a multi-line string value:


This isn’t ideal if you’re searching for something specific, or you just want a nicely-formatted output. I’ve created a quick PowerShell function that outputs these values, and allows you to use standard PowerShell operations to search and filter.

For example, output to a text file:

Get-PerformanceCounter | Out-File c:\temp\perfcounters.txt

Results in this:

Or you could do something like this:

Get-PerformanceCounter | Where-Object {$_.CounterName -like 'file write*'}

Which results in this:

CounterID CounterName              
--------- -----------              
       12 File Write Operations/sec
       18 File Write Bytes/sec

Or, you could sort them by name:

Get-PerformanceCounter | Sort-Object -Property 'CounterName' | Format-Table -AutoSize

Which would result in the following output

CounterID CounterName                                                   
--------- -----------                                                   
     7024 # Bytes in all Heaps                                          
    10686 # exceptions                                                  
     7014 # GC Handles                                                  
     6986 # Gen 0 Collections                                           
     6988 # Gen 1 Collections                                           
     6990 # Gen 2 Collections                                           
    10688 # images                                                      
     7018 # Induced GC                                                  
     7124 # Link Time Checks                                            
     7086 # of CCWs                                                     
     7108 # of current logical Threads                                  
     7110 # of current physical Threads                                 
     7112 # of current recognized threads                               
     7150 # of Exceps Thrown                                            
     7152 # of Exceps Thrown / sec                                      
     5046 # of failed workflow jobs                                     
     5048 # of failed workflow jobs/sec                                 
     7154 # of Filters / sec                                            
     7156 # of Finallys / sec                                           
     7072 # of IL Bytes Jitted                                          
     7090 # of marshalling                                              
     7070 # of Methods Jitted                                           
     7030 # of Pinned Objects                                           
     5050 # of resumed workflow jobs                                    
     5052 # of resumed workflow jobs/sec                                
     5054 # of running workflow jobs                                    
     5056 # of running workflow jobs / sec                              
     7032 # of Sink Blocks in use          

Here’s the code:

function Get-PerformanceCounter
# Get the Performance Counters from the Registry
$counters = Get-ItemProperty Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Perflib\009' Name 'counter' | Select-Object ExpandProperty Counter
# Remove the last line
$counters = $counters | Select-Object SkipLast 1
# Split the string into an array
$counters = $counters.Split([Environment]::NewLine)
$counterList = @()
for ($x = 0; $x -lt $counters.Count; $x++)
if ($x % 2 -eq 0) {
$counterList += New-Object TypeName PSObject Property @{ CounterID = [int]$counters[($x -2)];CounterName = [string]$counters[$x 1] }
$counterList | Sort-Object Property 'CounterID'
# Get performance counters sorted by ID
# Get-PerformanceCounter | Sort-Object -Property 'CounterID' | Format-Table -AutoSize
# Search for specific performance counters by name
# Get-PerformanceCounter | Where-Object {$_.CounterName -like 'file write*'}
# Get performance counters, sorted by name
Get-PerformanceCounter | Sort-Object Property 'CounterName' | Format-Table AutoSize

One thought on “Use PowerShell to list all Windows Performance Counters and their numeric IDs

Leave a Reply to Chrissy LeMaire Cancel reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s