During a recent upgrade of Azure AD Connect I encountered the following error in the Application event log:
Log Name: Application
Date: 05-12-2016 11:28:21
Event ID: 6313
Task Category: Server
The server encountered an unexpected error creating performance counters for management agent “adatum.dk”.
Performance counters will not be available for this management agent.
After analyzing the issue in details I found that this occur when AAD Connect installation lack permissions to write performance counter information correctly in the local Registry.
To avoid this issue in the first place, always start Azure AD Connect installation or upgrade from an elevated command prompt or an elevated PowerShell prompt.
Fixing the issue after Azure AD Connect is installed, require either that AAD Connect is first un-installed and then properly re-installed (from an elevated command prompt), or that the following changes are done to re-register the ADSync performance counters.
To perform re-registration of the ADSync performance counters, first open an elevated PowerShell prompt and stop the three Azure AD Connect services:
Next, we need to make a change in the local Registry, but before this ensure that you have a backup of the Registry key.
Open the local Registry and right-click on the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\ADSync\Performance key
Select Export and save the key to a .REG file
Right-click the following registry key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\ADSync\Performance and select Delete
Before proceeding, create a new Performance key in the Registry under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\ADSync\
Switch back to the elevated PowerShell prompt and two commands to unload and create the performance counters.
Run the first command to remove performance counters name and explain text for the ADSync performance counters:
Run the second command to register name and explain text of the ADSync performance counters, based on the information in the mmsperf.ini file:
lodctr.exe “C:\Program Files\Microsoft Azure AD Sync\Bin\mmsperf.ini”
Start the Azure AD Connect service from the elevated PowerShell prompt:
Review the Application log for the event ID 1000 for confirmation that the performance counters are successfully loaded:
Log Name: Application
Date: 05-12-2016 11:43:41
Event ID: 1000
Task Category: None
Performance counters for the ADSync (Microsoft Azure AD Sync) service were loaded successfully.
The Record Data in the data section contains the new index values assigned to this service.