How To Disable Azure AD Connect via PowerShell

Recently I came across an environment where Exchange was being migrated to Office 365. As you may know, DirSync is no longer supported for Exchange/O365 migrations and Microsoft recommends you now use Azure AD Connect.

With that said, recently in a PoC environment, using Azure AD Connect, the domain controller that was running the Azure AD Connect utility was never uninstalled, and the VM was shortly deleted. Well, as a result, the O365 admins are now getting reminded daily that their AD Sync has failed to connect.

As of today, there is no way to disable Azure AD Connect via the Azure Resource Manager (ARM) portal, but this can be done with some PowerShell. If you take a look at the ARM portal, there is no option to currently disable the directory synchronization.

First, you will need to install the Azure Active Directory Connection utility, the download for that can be found HERE. This will provide you the PowerShell cmdlet’s needed to run the code below. No, AzureADPreview V2 will not work (yet…).

Once installed, launch the PowerShell console and we will need to connect to Azure AD and trigger the Directory Sync to false. Below are the commands you will need to get this done. Note, you will need an Azure global admin account with the *@* domain to successfully sign into Azure AD via PowerShell.

#specify credentials for azure ad connect
$Msolcred = Get-credential
#connect to azure ad
Connect-MsolService -Credential $MsolCred
#disable AD Connect / Dir Sync
Set-MsolDirSyncEnabled –EnableDirSync $false 
#confirm AD Connect / Dir Sync disabled

If you choose to re-enable the AD Connect, just change the flag to TRUE.

Set-MsolDirSyncEnabled –EnableDirSync $true 

Once complete, we can now verify the Directory Sync has now been disabled in ARM.

For more on Azure AD PowerShell cmdlets, visit the following page, HERE.


5 thoughts on “How To Disable Azure AD Connect via PowerShell

  1. If an AD account synced from on prem to Azure and you run remove DirSync/AAD Connect in this way, do the objects change from ‘Windows Server AD’ to ‘Azure Active Directory’ or ‘Cloud’. I want to break the link between my AD and AAD but I don’t want to be unable to edit attributes of objects because they are still expecting changes to be fed from on-prem. Does that make sense?


    1. Hi, so once the sync is broken, you can make changes in either environment, and the changes will not be reflected in the counter-environment. Keep in mind, AD Connect is not a two-way sync, only one way. It will only sync from source to target (AD -> AAD). I hope that helps.


  2. May I simply say what a relief to find a person that truly understands what they’re discussing on the internet. You actually realize how to bring an issue to light and make it important. More and more people really need to read this and understand this side of the story. I can’t believe you are not more popular given that you surely possess the gift.


Leave a Reply

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

You are commenting using your 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

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