How to Remove On-Premises Directory Synchronization Service Account from Microsoft 365

If you are trying to rebuild the Azure AD Connect server, but you noticed y the Delete user is greyed out and you cannot delete the existing On-Premises Directory Synchronization Service Account from Microsoft 365 admin center.

I will show you how to use the PowerShell cmdlets to remove it.

1. Open a Windows PowerShell Command Prompt window.

2. Run the below command and enter Yes to install and import the NuGet provider.

Install-Module MSOnline

3. Enter Yes to install PSGallery.

4. Run the below cmdlets to connect Microsoft 365 Tenant. Enter your username and password and click OK.

$msolcred = get-credential

connect-msolservice -credential $msolcred

5. Run the below cmdlet to disable directory synchronization and enter Yes to confirm.

Set-MsolDirSyncEnabled –EnableDirSync $false

6. Run the below cmdlet to check the directory synchronization status.

(Get-MSOLCompanyInformation).DirectorySynchronizationEnabled

7. Run the below cmdlet to remove the Directory Synchronization Service Account and enter Yes to confirm.

Remove-MsolUser -UserPrincipalName Sync_ADCONNECT01_ce8add722dc4@angussun.onmicrosoft.com

8. Ensure the Sync_ADCONNECT01_ce8add722dc4@angussun.onmicrosoft.com.

9. Run the below cmdlet to enable directory synchronization and enter Yes to confirm.

Set-MsolDirSyncEnabled -EnableDirSync $true

10. Run the below cmdlet to check the directory synchronization status.

(Get-MSOLCompanyInformation).DirectorySynchronizationEnabled

I hope you enjoy this post.

Cary Sun

Twitter: @SifuSun

Web Site: carysun.com

Blog Site: checkyourlogs.net

Blog Site: gooddealmart.com

About Post Author

Leave a Reply