Well, there are situations you need to delete an Office 365 (MSOL) account permanently.
E.g., I need to create a new account with the same name but for a different user. Since there is a deleted MSOL account still exists, you can’t create the new user.
It is very easy. Open PowerShell and connect to AzureAD:
Connect-MSOLService -Credential (Get-Credential)
First you need to get the ObjectID of the deleted account. Here is how you do it.
-ReturnDeletedUsers -searchstring *UserUPN here* | fl UserPrincipleName,
Example: Get-MsolUser -ReturnDeletedUsers -searchstring JohnDoe@mycompany.com | fl UserPrincipleName, ObjectID
Now note down the ObjectID from the above command and use it for next command. Then we need to purge the deleted account.
-ObjectID *ObjectID here* -RemoveFromRecycleBin -Force
-ObjectID c4d86044-bd23-7218-c226-e556a25a2dac -RemoveFromRecycleBin -Force
That’s it. You sent this specific MSOL account to Hell forever.
Now, do you want to “Purge” all deleted MSOL accounts? Get Nasty. Here is how you do it.
Get-MsolUser -ReturnDeletedUsers -All |
Remove-MsolUser -RemoveFromRecycleBin -Force