The Azure AD Connect tool is great to sync user passwords from Active Directory to Office 365. However, sometimes it can malfunction and it needs to be reinstalled. The reinstall process can sometimes encounter errors such as not being able to install the synchronization service. If you encounter errors during the reinstall process here is how to manually remove the Azure AD Connect tool.

Since changes will be made to the registry, we highly recommend making a backup beforehand.

  1. First, try to uninstall the following applications by using “Programs and Features” in Control Panel in the following order:
    1. Azure Active Directory Sync tool
    2. Microsoft Azure Active Directory Connector
    3. Microsoft Azure AD Sync
    4. Microsoft Azure Active Directory Synchronization
    5. Microsoft Online Services Sign-in Assistant (Restart is required)
    6. Forefront Identity Manager Synchronization Service
    7. Microsoft SQL Server 2012 Express LocalDB
    8. Microsoft SQL Server 2012 Native Client
    9. Microsoft SQL Server 2012 Command Line Utilities
  2. For each application that failed to uninstall, follow these steps (if none failed, skip this section and go to step 3):
    1. Open Command Prompt as Administrator
    2. Open Registry Editor, and then locate the following registry entry:
    3. HKEY_LOCAL_MACHINE/Software/Microsoft/Windows/CurrentVersion/Uninstall
    4. For each entry that’s listed in the Uninstall registry subkey, examine the DisplayName value to identify the entry that represents the application that could not be uninstalled by using “Programs and Features”
    5. For each application, run the following command at the command prompt, where “{Product Code}” is the alphanumeric entry in the Uninstall registry subkey that represents the application: Msiexec /quiet /x "{ Product Code }" /l*v uninstall.log EXECUTE_UNINSTALL="1"
    6. Review the log that’s generated (for example, Uninstall.log) and troubleshoot error messages.
    7. Remove the registry entry for each application in the list.
  3. Next, remove the following registry entries:
    1. HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\MSOnlineSyncScheduler
    2. HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\ADSync
    3. HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\eventlog\Application\AzureActiveDirectoryDirectorySyncTool
    5. HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Azure AD Connect
    7. HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\Instance Names\SQL\MSONLINE
    9. HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL.N
    10. HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\InstalledInstances (NOTE: Don’t delete the whole string key for this entry, just delete MSONLINE from InstalledInstances)
    12. HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server Local DB
    13. HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\MicrosoftAzureADConnectionTool
    14. HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tasks\{0311B5B5-B05D-47A0-89D8-98AED5A0D204}
    15. HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Azure AD Sync Scheduler
    16. HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Tracing\AzureADConnect_RASAPI32
    17. HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Tracing\AzureADConnect_RASMANCS
    18. HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server Local DB\Shared Instances\ADSync
    19. HKEY_CURRENT_USER\Software\Microsoft\Azure AD Connect
    20. HKEY_CURRENT_USER\Software\Microsoft\AD Sync
    21. HKEY_CLASSES_ROOT\TypeLib\{1EE655FB-EC8A-4CFE-BFE7-E8D46BC87B6A}
  4. Now delete the following folder locations:
    1. %ProgramFiles%\Microsoft SQL Server\MSSQL.N
    2. %ProgramFiles%\Microsoft Online Directory Sync
    3. %ProgramFiles%\Microsoft Azure AD Connection Tool
    4. %ProgramFiles%\Microsoft Azure AD Sync
    5. %ProgramFiles%\Microsoft Azure Active Directory Connect
    6. %ProgramData%\AADConnect\PersistedState.xml
  5. Next, make sure the following user accounts are removed from the Local Users folder on the server:
    1. MIIS_Service
    2. AAD_nnnnnnnnnnnn (for example, AAD_5b61ac0e9acf)
    3. MSOL_nnnnnnnnnnnn (for example, MSOL_5b61ac0e9acf)
  6. Next, remove the following Task Schedulers:
    1. Azure AD Sync Scheduler
    2. MSOnlineSyncScheduler
  7. Restart the server
  8. Log back in and open Component Services. Click Start -> Run -> Component Services -> Computers -> My Computer -> Right click and select Properties -> COM Security -> Make sure the admin has all the Access Permissions and Launch and Activation Permissions
  9. Now install the Azure AD Connect tool as normal and it should work properly.