Manually Delete Office365 Users From Portal

Delete user account from pc

Home‎ > ‎

How to delete a user from Office 365 which has been synced with Dirsync

posted 15 Jul 2014, 06:27 by Colum Brady
Posted by : Harm-Jan van Tielzaterdag 15 oktober 2011

I have been testing some things with my account in Office 365.
Unfortunately, where people are testing, thing go wrong.
Somehow, my user in Office 365 got corrupted and all of my things in the cloud were unavailable.
Luckily , it was a test user and no actual data got lost.
First things first. I want to point out that deleting a user in Office 365 using this method also deletes the corresponding mailbox and all the other settings for other Office 365 products.
Only use this as a last effort to delete the user/mailbox.


So, we need to delete the user from Office 365. Easy, just log in to the portal, browse to the user and click delete. Well....no.
Because the users got synced with Dirsync, AD is leading and therefore the user can't be deleted from the portal.
Well, then I tried deleting the user with Microsoft Online Module for Powershell. ( Installed on ADFS )
First, connecting to the MSOLService and importing the cmdlets to manage Office 365.
Next step was removing the user with the following command.
'Remove-MSOLuser -userprincipalname 'userlogonname'
Again, AD is leading so powershell gave me the following error.

Then I thought, AD is leading, Dirsync is ILM, so there must be another way.
And there is! Using the ILM console we can successfully delete a user from Offie 365, without deleting the user in AD.
It is recommended to do this just after a sync, because we don't want Dirsync to start syncing while we are changing things in ILM.
Open the ILM console on the Dirsync server : C:Program FilesMicrosoft Online Directory SyncSYNCBUSUIShellmiiclient.exe
Then open the tab ' Metaverse Search'
The metaverse is a database that keeps track of user data from all the connected systems.
In this case we only have 2 systems, AD and Office 365.
So in the met averse search we will find one User ( person ) with data from AD and Office 365.
Create a new search scope to find the user you want to delete from Office 365.
Once the user is found, double click the user.

Open the tab 'Connectors' .
You will see 2 connectors, one with all the imported data from AD, and one with all the exported data to Office 365.
Select the AD connector ( where Management Agent value is SourceAD) and click 'Disconnect' so only the Office 365 connector ( TargetWebService ) remains.
This simulates the user being deleted from AD, as there is no longer any data present for the AD connector.

Next, go to the Management Agents tab.
Right click the 'TargetWebService' connector and choose 'Run'.
Select the 'Full Confirming Import' run profile and click ok.

Repeat the steps above and choose the 'Export' run profile instead of the Confirming Import.
When the export is finished, the user object is deleted from Office 365.
This is also shown in the history under the operations tab in ILM.
Click the last task and the deletion will be shown in the bottom left corner.
In the next Sync the user will be recreated in Office 365.
If you want to create a new on-premise mailbox for the user ( because the Online mailbox is deteled, and there is no on-prem mailbox ), there are a couple of extra steps to follow.
If you open the Exchange EMC right away and use the ' new-mailbox ' command for the just deleted user, you will notice the EMC cannot find your user as it searches for users with no mailbox.
To create a new mailbox for the existing user you have to clear all the exchange attributes in AD for that user. If you open the attribute editor you will notice that all the Exchange attributes remain in AD. If you don't clear the values, Exchange EMC will not create a new mailbox.
Open the properties of a user without a mailbox, and check which attributes had no value.
Clear the ones that don't have a value with the non mailbox enabled user.

Again, only use this as a last effort because all mailbox content is deleted.
If this happens with a normal user instead of a test user, there is a way to get your e-mails back.
With my test user, I opened outlook in Offline mode and created a PST, Cached mode needs to be enabled for this to work!
When the new mailbox was created I imported the PST and the e-mails are back.
Hope you don't have to use this, but it's good to know how a user can be deleted.
Delete user account from pcComputer

Delete User Account From Pc

Nov 14, 2019  I change the password and then manually disconnect all O365 sessions. (O365 portal, Users, select the user - on the right side expand the OneDrive section and you sign out all active sessions there) Then I delete the rules, checking both Outlook (all devices the user has it installed on) and OWA.