Jump to content

- - - - -

Delete user from Office 365 Hybrid with DirSync

Posted by Pantelis Apostolidis , in Office 365 23 December 2014 · 4,422 views

office 365 powershell

This post is bout Exchange/Office 365 Hybrid Deployments, when for some reason we need to completely delete a user account and mailbox from Office 365 in order to re-sync it.


First you need to exclude the user from DirSync

  • Open the “Synchronization Service Manager” (cn be fount at “C:\Program Files\WindowsAzureActiveDirectorySync\SYNCBUS\Synchronization Service\UIShell\miisclient.exe”)
  • Navigate to “Metaverse Search” and click on “Add Clause”
  • Be sure that you choose Displayname as Attribute, and then configure your search
  • Double click an entry, and open the tab connectors
  • Activate the line with the “Active Directory Connector” Management Agent and click on “Disconnect…
  • In the disconnect object accept question, choose “Disconnector (Default)” to remove the connector. Explicit Disconnector will lock the object to be a connector again.
You can then rerun your search, and the specific account will not be shown anymore. And after a sync, the object will also be removed from the azure Directory


Then you need to remove the user object from the Office 365 portal using the PowerShell

  • Open PowerShell “Windows Azure Active Directory Module”
  • $msolcred = get-credential
  • connect-msolservice -credential $msolcred
  • Get-MsolUser -ReturnDeletedUsers | FT UserP*,ObjectId
  • Remove-MsolUser -ObjectId abc1234-12abc-123a-ab12-a12b3c4d5f6gah -RemoveFromRecycleBin -Force
  • Get-MsolUser -ReturnDeletedUsers | Remove-MsolUser -RemoveFromRecycleBin -Force
Then at the next scheduled sync of te DirSync the user will be recreated. Also you can force the DirSync to creaate the user faster.


soure: http://www.e-apostol...5-with-dirsync/