Where are my Exchange 2016 Performance Counters?

So in my lab, I’ve got a handful of Exchange Servers and I’m monitoring them with my SolarWinds Orion Server.

I did all the basics that I normally do when troubleshooting an Application Template that doesn’t seem to be pulling data properly and then I finally got on the server itself and checked for the Performance Counters.  I opened PerfMon on that machine and got this lovely error.

What the what?
What the what?

Searching around, I found this solution.  Now before I reload all the counters from the cache, I wanted to make sure that my Exchange Counters would be returned to their upright position.

For the Exchange Counters, I found me an article and another one that explained how to do restore my performance counters for Exchange 2013 and 2010 server.

Now this is an Exchange 2016 server, so I went to the same (relative) location and looked for similar files.

Eureka!  Same place!
Eureka! Same place!

So then I thought about going through all of the counters that I need to replace and importing them one at a time.  Then I thought again.  PowerShell to the rescue!

$InstallPath = Get-Item -Path ( Get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\ExchangeServer\v15\Setup -Name MsiInstallPath | Select-Object -ExpandProperty MsiInstallPath ) -ErrorAction SilentlyContinue

Add-Pssnapin Microsoft.Exchange.Management.PowerShell.Setup
$PerfFiles = Get-ChildItem -Path ( Join-Path -Path $InstallPath -ChildPath "\Setup\Perf\*.xml" )
$i = 0; $iCount = $PerfFiles.Count
ForEach ( $PerfFile in $PerfFiles )
{
    $CounterName = ( ( Get-Content -Path $PerfFile.FullName ) ).Category.Name
    Write-Progress -Activity "Updating Performance Counters" -CurrentOperation "[$( $i + 1 )/$( $iCount )] $( $CounterName )" -PercentComplete ( ( $i / $iCount ) * 100 )

    Write-Host "Removing Performance Counter: $CounterName" -Foreground Red
    Remove-PerfCounters -DefinitionFileName $PerfFile.FullName
    Write-Host "Adding Performance Counter: $CounterName" -Foreground Green
    New-PerfCounters –DefinitionFilename $PerfFile.FullName
    $i++
}
Write-Progress -Activity "Updating Performance Counters" -Completed

I have a love/hate relationship with the “Write-Progress” function, but here it seemed worthwhile because of the sheer number of performance counters (254 in my environment).

Please note that this is a lab machine and as such is non-production.  I have no idea if these steps would impact service availability.  If you have a properly configured Database Availability Group, just fail all your databases to other servers and you should be fine.  When in doubt, refer to this page.

After the Exchange Performance Monitors are added back, I ran the lodctr command to rebuild the counters.  Then just to be safe, I ran it a second time to make sure that there were no errors.

Since I had no active databases on this server, I rebooted it.  You probably don’t need to do that, but… why not, right?  All your databases are active and protected on other servers, right?

After a few minutes SolarWinds Server & Application Monitor started reading and recording the metrics!

Counters are Back!
Counters are Back!

For an Exchange Admin, there’s nothing more satisfying than knowing that your servers are healthy and your users can access their content – even if it is just a lab environment!

Until next time ramblers!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.