You've probably seen them too, lots of errors in the Application log of your Exchange 2013 server from source MSExchange Common and event id 106.
Performance counter updating error. Counter name is PowerShell Average Response Time, category name is MSExchangeRemotePowershell. Optional code: 2. Exception: The exception thrown is : System.InvalidOperationException: The requested Performance Counter is not a custom counter, it has to be initialized as ReadOnly.
The issue is caused by an error in the Exchange setup process where a performance counter definition is tried to read from the wrong location.
The good news is that we can fix this very easy. Copy the following script to a text file and save with the .ps1 extension.
Add-PsSnapin Microsoft.Exchange.Management.PowerShell.Setup
$files = Get-ChildItem $exinstall\setup\perf\*.xml
Write-Host "Registering the perfmon counters"
Write-Host
$count = 0;
foreach ($i in $files)
{
$count++
$f = $i.directory, "\", $i.name -join ""
Write-Host $count $f -BackgroundColor red
New-PerfCounters -DefinitionFileName $f
}
Run the script from an Exchange management shell.
If you run into issues you can manually retry the process for that specific performance counter definition. For instance, to retry the failed counter definition from the screenshot above you can retry the action:
Add-PsSnapin Microsoft.Exchange.Management.PowerShell.Setup
New-PerfCounters -DefinitionFileName "C:\Program Files\Microsoft\Exchange Server\V15\setup\perf\WorkerTaskFrameworkPerfCounters.xml"
Interesting detail is that Microsoft apparently wrote a KB article about this issue back in 2013 which I failed to pick up. I modified the script to work on servers with Exchange installed in a non-default path. If you prefer to use the original one, don't forget to change the path manually.
13 comments:
Thank you for posting this!
This was worked great!
Perfect! Greate Info.
Works on Exchange 2016 as well, thanks!
Thank you for this fix. It worked for Exchange 2016 as well. One question, every-time I restart exchange server, I get these errors and have to run the script to reinstall the perflib. Any idea what could be causing that?
Here same issue as clreply2020
After a reboot same issue again with exchange 2016.
Any update on this?
My Application log is quite literally full of these inane errors on my Exchange 2016 server. This workaround appears to no longer work. Come-on Microsoft, make this smarter and allow us to turn this off.
I too am getting these in Exchange 2016 CU2. Any updates???
Same here, have to run the workaround after each server start
What is 1 counter fails with the Add-PsSnapin Microsoft.Exchange.Management.PowerShell.Setupcountername.xml command.
Is there another potential thing once could try to force fixing the counter?
I installed a clean server with Exchange 2016 CU3 in a mailbox role. Also getting error 106 on restart.
I have also done a clean install of Exchange 2016 CU3 and am getting my event log filled with 106 errors. Has anyone a fix for this yet? Thanks Edd
Cu4 clean install still getting these errors.
Post a Comment