skip to Main Content

Permanently delete users from Office 365

How to permanently delete users from Office 365/Microsoft 365? When you remove users from Office 365/Microsoft 365, they will move to the recycle bin. This is known as soft-delete. A soft-delete user account will stay for 30 days. After that, it will automatically be deleted by Microsoft. This is known as hard-delete. What if you don’t want to wait and like to remove the deleted users manually? Let’s have a look at how to force delete users from Office 365 with PowerShell.

Soft-deleted user vs. Hard-deleted user

  • A soft-deleted user is a user that has been deleted and has still been in the Azure Active Directory recycle bin for less than 30 days.
  • A hard-deleted user is a user that has been deleted and is not available in the Azure Active Directory recycle bin.

Find deleted users in Microsoft 365 admin center

You can find the deleted users in Microsoft 365 admin center. Navigate to Users > Deleted Users.

Permanently delete users from Office 365 admin center

You can’t remove the deleted users from Microsoft 365 admin center. The only possible way to remove the deleted Office 365 users is with PowerShell.

Let’s look at that in the next step.

Connect to Azure AD with PowerShell

Install and connect to Azure AD with PowerShell. After that, run the Connect-MsolService cmdlet to initiate a connection with Azure Active Directory.

PS C:\> Connect-MsolService

After running the above cmdlet, the sign-in window shows up. Fill in the credentials and sign in.

Permanently delete users from Office 365 sign in

After connecting to Azure AD with PowerShell, let’s get the deleted Office 365 users.

Get Office 365 deleted users

Find the Office 365 deleted users with PowerShell. Run the Get-MsolUser cmdlet, including the -All switch and -ReturnDeletedUsers switch.

PS C:\> Get-MsolUser -All -ReturnDeletedUsers | Sort-Object DisplayName

UserPrincipalName         DisplayName     isLicensed
-----------------         -----------     ----------
Audrey.Paige@exoip.com    Audrey Paige    True      
Emily.Blake@exoip.com     Emily Blake     True      
Frank.Davies@exoip.com    Frank Davies    True      
Jane.Graham@exoip.com     Jane Graham     True      
Joseph.Bond@exoip.com     Joseph Bond     True      
Leonard.Hudson@exoip.com  Leonard Hudson  True      
Peter.Morrison@exoip.com  Peter Morrison  True      
Rachel.Hamilton@exoip.com Rachel Hamilton True      
Ruth.Hunter@exoip.com     Ruth Hunter     True      
Ryan.Smith@exoip.com      Ryan Smith      True      
Sophie.Lewis@exoip.com    Sophie Lewis    True      
svd-adds@exoip.com        svc-adds        False     

Remove specific deleted Office 365 user

Permanently remove a single deleted user.

PS C:\> Remove-MsolUser -UserPrincipalName "Audrey.Paige@exoip.com" -RemoveFromRecycleBin

Remove all deleted Office 365 users

Permanently remove all deleted users.

PS C:\> Get-MsolUser -All -ReturnDeletedUsers | Remove-MsolUser -RemoveFromRecycleBin -Force

After running the above command, we can verify that the deleted users page is empty.

Permanently delete users from Office 365 admin center empty

Remove all deleted Office 365 users from a domain

If you like to permanently remove deleted Office 365 users that end with a specific domain, you can filter on UserPrincipalName.

In our example, it’s the domain exoipv2.com.

PS C:\> Get-MsolUser -All -ReturnDeletedUsers | Where-Object {$_.UserPrincipalName -like "*exoipv2.com"} | Remove-MsolUser -RemoveFromRecycleBin -Force

That’s it! Did this help you to force delete Office 365/Microsoft 365 users from recycle bin?

Keep reading: Export Office 365 mailbox permissions to CSV »

Conclusion

You learned how to delete users from Office 365 permanently. Most of the time, you delete users, and they will move automatically to the Azure Active Directory recycle bin (soft-delete). After 30 days, Microsoft will remove the deleted users from the Azure Active Directory recycle bin (hard-delete). The next time you want to hard-delete the users and don’t want to wait 30 days, you can use PowerShell.

Did you enjoy this article? You may also like Export Office 365 mailbox to PST. Don’t forget to follow us and share this article.

ALI TAJRAN

ALI TAJRAN

ALI TAJRAN is a passionate IT Architect, IT Consultant, and Microsoft Certified Trainer. He started Information Technology at a very young age, and his goal is to teach and inspire others. Read more »

This Post Has 0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *