To purge and resynchronise an AD synchronised with DirSync account from Office 365, follow these steps:

1.    Fire up Windows Azure Active Directory for Windows PowerShell (Check out managing Office 365 through Azure PowerShell here).

2.    Run the following command to connect to online service, remembering substitute our friend Fakey McFakerson for your own admin credentials.


3.    Now, we need to grab the user Object ID. Once you obtained it copy and paste it elsewhere as you’ll need it later.


4.    Ok, now that we have the user Object ID we can remove the account.


5.    With the account removed, we now need to purge the account from the Office 365 Recycle Bin. This is where we use the Object ID obtained earlier. Run the following command to purge the user from recycle bin.



With the user(s) accounts purged from Office 365 you need to perform the Directory Synchronisation (unless you are happy to wait for it to sync on the next run? Default is every three hours).

6.   To force immediate directory synchronization, type the following into a run window on the Directory Synchronisation server:

C:Program FilesMicrosoft Online Directory SyncDirSyncConfigShell.psc1

This opens up a PowerShell window with the appropriate synchronisation commands pre-loaded.

7.   Type the following at the command prompt –


And that is it my friends, relatively quick and painless compared to the alternative of having to delete and recover an AD account or recreate from scratch. Remember to leave a comment or a like if this helps you out. Here is the code in a single block for you to copy and paste with greater ease…