Note: A newer version of this article is available.
When you delete a user from the Office 365 control panel they are moved into a recycle bin for 30 days so that they can be recovered easily if the deletion was not intended.
However, if you want to permanently remove a deleted user in Office 365 you can use PowerShell. For this task you will need the Azure Active Directory for PowerShell module installed on your computer.
First, connect to your Azure Active Directory by running Connect-MsolService and entering your admin credentials in the dialog box that appears.
Caution: do not proceed unless you are completely sure that you want to permanently remove the users.
PS C:Scripts> Connect-MsolService
To see a list of the deleted users run Get-MsolUser with the -ReturnDeletedUsers switch.
PS C:Scripts> Get-MsolUser -ReturnDeletedUsers
You can remove a specific deleted user with Remove-MsolUser and the -RemoveFromRecycleBin switch.
PS C:Scripts> Remove-MsolUser -UserPrincipalName Lynn@office365bootcamp.com -RemoveFromRecycleBin Confirm Continue with this operation? [Y] Yes [N] No [S] Suspend [?] Help (default is "Y"): y
To remove all deleted users you can pipe the Get-MsolUser output to Remove-MsolUser and add the -Force switch to avoid being prompted for each removal.
Caution: be very careful here not to accidentally delete all users from your Azure Active Directory.
PS C:Scripts> Get-MsolUser -ReturnDeletedUsers | Remove-MsolUser -RemoveFromRecycleBin -Force