Skip to main content

Emptying the Office 365 Recycle Bin

By January 28, 2013June 1st, 2022Blog, Microsoft, Office 365, Office 365

In the midst of a migration to Office 365 recently, I needed to re-do some work, which required re-creating some accounts. Deleting accounts is easy enough, but the recreation failed because the accounts still existed. Office 365 has a recycle bin that automatically removes items after 30 days. If you need to clean it out a bit faster, there is a way.

First, be sure to grab the latest “Microsoft Online Services Module for Windows Powershell” (MSOL Module PowerShell): https://onlinehelp.microsoft.com/en-us/office365-enterprises/hh124998.aspx

Then, Set-executionpolicy unrestricted

Connect to Office 365: Connect-MSOLService

Once connected, Get-MsolUser –ReturnDeletedUsers will show all the users in the Recycle Bin and Remove-MsolUser – user@domain.com – RemoveFromRecycleBin will remove individual. If you want to remove everything from the Recycle Bin, can you pipe one to the other: Get-MsolUser –ReturnDeletedUsers | Remove-MsolUser –RemoveFromRecycleBin.

Now your Office 365 recycle bin is empty and you can get back to your transition to the Cloud.

Shane Skriletz, PEI

 

One Comment

  • the command is actually

    For ALL recycle bin:
    Get-MsolUser -All -ReturnDeletedUsers | Remove-MsolUser -RemoveFromRecycleBin –Force

    For Set Number: (example mine is 30)
    Get-MsolUser -MaxResults 30 -ReturnDeletedUsers | Remove-MsolUser -RemoveFromRecycleBin –Force

Leave a Reply