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 – firstname.lastname@example.org – 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