Hi There

Even if you’re doing LABs, PoC (Proff of conceps) or rolling Azure AD connect (AD sync) on production sometimes you might face the follow error message:

Delete user failed
We couldn’t delete this account: Sync_SRV-DC01_8f0a01761ef9@tecbis.onmicrosoft.com. This is your directory synchronization account and you’ll have synchronization failures if it’s deleted.

 

To fix this do the following:

Connect to your Office 365 Tenant using PowerShell

$msolcred = get-credential

connect-msolservice -credential $msolcred

Disable directory synchronization. To do this, type the following cmdlet, and then press Enter:

Set-MsolDirSyncEnabled –EnableDirSync $false

Check that directory synchronization was fully disabled by using the Windows PowerShell. To do this, run the following cmdlet periodically:

(Get-MSOLCompanyInformation).DirectorySynchronizationEnabled

This command will return True or False. Continue to run this periodically until it returns False, and then go to the next step.

Note It may take 72 hours for deactivation to be completed. The time depends on the number of objects that are in your cloud service subscription account.

Remove-MsolUser -UserPrincipalName Sync_SRV-DC01_8f0a01761ef9@tecbis.onmicrosoft.com

Refresh, and the user will have moved to “deleted users.”  You can delete it from there, or leave it alone and left Azure kill it off in 30 days.

Re-enable Directory Synchronization

To re-enable directory synchronization, run the following cmdlet:

Set-MsolDirSyncEnabled -EnableDirSync $true

Reference

https://support.microsoft.com/en-ca/help/2619062/you-can-t-manage-or-remove-objects-that-were-synchronized-through-the

https://docs.microsoft.com/en-us/previous-versions/azure/jj151815(v=azure.100)?redirectedfrom=MSDN

thanks,

Thiago Beier
TwitterLinkedInFacebookRSS