Removing Azure AD Connect With PowerShell

The first thing to do is to launch PowerShell as an Administrator, and once inside, there are only two simple commands to provide. An Azure/Office 365 Global Admin account will be required, so be sure to have one handy.

These commands require the MSOnline module. If you don’t have this module installed, simply run the following in PowerShell:

Install-Module MSOnline

This will result in a prompt notifying that an untrusted repository is being used for the module installation. Answering yes will allow the installation.

Once the module is installed, the below can be run to connect to Azure.

$Msolcred = Get-credential
Connect-MsolService -Credential $MsolCred

A pop-up Window will appear. This is where Global Admin credentials are required. Providing the correct credentials will return focus to PowerShell.
Next, Directory Sync can be disabled by entering the below in PowerShell.

Set-MsolDirSyncEnabled –EnableDirSync $false

Note that setting the above value to true would enable Azure AD Sync.

To see that AD Connect and Sync has been disabled, the following can be used:

(Get-MSOLCompanyInformation).DirectorySynchronizationEnabled

The below screenshot shows the above steps within PowerShell:

Removing Azure AD Connect with Powershell
Removing Azure AD Connect with Powershell

Next, we’ll verify within the Azure and Office 365 web consoles that AD Sync has been stopped, and we will also remove the AD Sync account.

Leave a comment

© Copyright MMXVIII Tony Moreira Dot Com