Permanently Delete Users from Office 365 Admin Portal
In Microsoft 365, when users are deleted, they are not immediately removed from the system. Instead, they are moved to a recycle bin in Azure Active Directory (Azure AD), where they are retained for a period in case recovery is needed. However, there are situations where you might need to permanently delete these users to ensure compliance with data retention policies or to free up user principal names (UPNs) for reuse. This process involves using specific PowerShell cmdlets to connect to Azure AD, list the deleted users, and then permanently remove them. Below are the technical steps required to accomplish this.
Step 1: Connect to Azure AD
First, run the Connect-MsolService cmdlet to initiate a connection with Azure Active Directory.
Connect-MsolService
Step 2: List Deleted Users
To see a list of the deleted users, run the following command:
Get-MsolUser -ReturnDeletedUsers
Step 3: Remove a Specific Deleted User
To remove a specific deleted user, use the following command, replacing [email protected] with the user principal name:
Remove-MsolUser -UserPrincipalName [email protected] -RemoveFromRecycleBin
Step 4: Remove All Deleted Users
To remove all deleted users at once, run the following command:
Get-MsolUser -ReturnDeletedUsers | Remove-MsolUser -RemoveFromRecycleBin -Force