Manage Office 365 Recycle bin by using PowerShell | Office 365 5/5 (2) 4 min read

In the current article, we will review how to use PowerShell commands for managing the recovery of user’s accounts in Office 365 environment.

Office 365 Active Directory provides the option to recover office 365 deleted user account.
Each of “deleted user account” will be saved in the Active Directory Recycle bin for 30 days.

When we delete a user account, the operation described as “Soft Delete” because the user account not deleted completely.

Management tasks relating to soft delete are:

  1. Recover Deleted User account.
  2. Delete (remove) Deleted user account – delete a user object from the Active Directory Recycle bin (describes as Hard Delete). This option is suitable for scenarios in which the deleted user account “Blocks” creation of new user account with an identical display name or UPN.

In the article, we review the management of the deleted account by using PowerShell commands.

PowerShell | Help & additional information

Running PowerShell commands in Office 365 based environment
To be able to run the PowerShell commands specified in the current article, you will need to create a remote PowerShell with Azure Active Directory or Exchange Online. In case that you need help with the process of creating a Remote PowerShell session, you can use the links on the bottom of the Article.

Restore Deleted Office 365 User account

Restore Deleted Office 365 User account

PowerShell command syntax

PowerShell command Example

Restore ALL Deleted Office 365 User accounts (BULK Mode)

PowerShell command Example

Restore Deleted Office 365 User account and use Auto Reconcile Proxy Conflicts

PowerShell command syntax

PowerShell command Example

Display information about Office 365 Deleted user accounts

Display information about Specific Office 365 deleted User account

PowerShell command syntax

PowerShell command Example

Display a list of ALL Office 365 deleted user accounts

PowerShell command Example

Delete (Remove) User account from the Recycle bin

Delete (Remove) deleted user account from the Recycle bin (Hard delete)

PowerShell command syntax

PowerShell command Example

Delete (Remove) ALL deleted user accountS from the Recycle bin BULK MODE (Hard delete)

PowerShell command Example

Export information about Deleted Office 365 User accounts

Export information about Deleted Office 365 User accounts to CSV file

PowerShell command syntax

PowerShell command Example


For your convenience, I have “Wrapped” all the PowerShell commands that were reviewed in the article,
in a “Menu Based” PowerShell Script.

You are welcome to download the PowerShell script and use it.
Download -o365info PowerShell Script

Manage Office 365 Recycle bin by using PowerShell | Office 365
In case you want to get more detailed information about how to use the o365info menu PowerShell script, you can read the following article

Getting started with Office 365 PowerShell

PowerShell Naming Conventions & general information
Get more information about the Naming Conventions that are used in the PowerShell articles – Help and additional information – o365info.com PowerShell articles
Creating a remote PowerShell session to Exchange Online 
To get more information about the required remote PowerShell commands that you need to use for connecting to Exchange Online, read the following article:
Connect to Exchange Online by using Remote PowerShell
Creating a remote PowerShell session to Azure Active Directory
To get more information about the required software component + the remote PowerShell commands that you need to use for connecting Azure Active Directory, read the following article: Part 2: Connect to Office 365 by using Remote PowerShell
Basic introduction to PowerShell in Office 365 based environment
If you are new in the PowerShell world, you can read more information about how to start working with PowerShell in Office 365 based environment in the following article series:  Getting started with Office 365 PowerShell – Part 1, Part 2, Part 3.
Running and using o365info PowerShell scripts
In case that you need more information about how to use the o365info PowerShell scripts that I add to the PowerShell articles, you can read the article – How to run and use o365info PowerShell menu script

PowerShell command syntax – Office 365 | Article series index

Now it’s Your Turn!
It is important for us to know your opinion on this article


Print Friendly, PDF & Email

Related Post

Please rate this

Eyal Doron on EmailEyal Doron on FacebookEyal Doron on GoogleEyal Doron on LinkedinEyal Doron on PinterestEyal Doron on RssEyal Doron on TwitterEyal Doron on WordpressEyal Doron on Youtube
Eyal Doron
Share your knowledge.
It’s a way to achieve immortality.
Dalai Lama

4 Responses to “Manage Office 365 Recycle bin by using PowerShell | Office 365”

  1. I tried to run the above command for empty the recycle bin where I have a deleted user,but I get
    The term ‘-RemoveFromRecycleBin’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included..
    Can you help,because I imported all the modules for office 365 and this command is not available?

  2. Hard delete should only be used as a very last resort when no other option is available. Once deleted in this manner there is NO opportunity for restoring this user or any of the data associated with that user.
    A deleted user should NEVER block creation of a new user, although in some cases it may appear that way because the new user creation results in attempting to restore a delete user – but that the restore has a conflict. Conflicts should only be surfaced on a restore operation.

Leave a Reply

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