Manage Retention Policy and Tags by using PowerShell | Office 365 5/5 (2) 6 min read

In the current article, we will review how to use PowerShell commands for managing Retention Policy in Exchange Online environment.

The retention policy is a very powerful feature of Exchange Online but at the same time, unfamiliar to the most of us.
The Retention policy enables us to manage mail item’s Retention. In other words: Manage email before the email manage you!

The “Retention policy” is a collection of Retention Tags. Each Tag includes setting or “action” that will be applied to Mail item after a specific amount of time (measured in days). The “Action” could be:

  1. Delete Mail items
  2. Move Mail item to the Archive

Exchange Online includes built-in default Retention policy (Default MRM Policy) that is applied automatically for each Office 365 Mailboxes.

In this article, we review PowerShell commands that relate to the Retention Policy.
An additional issue is the Folder Assistant; this is the Exchange Online process that runs in the background and enforces or applies the Retention Policy on the Office 365 Mailboxes.

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.

1. Manage Retention Policy | Apply Retention Policy

1.1 – Apply Retention policy for a single Mailbox

PowerShell command syntax

PowerShell command Example

1.2 – Apply Retention Policy to ALL Office 365 Mailbox’s (Bulk Mode)

PowerShell command syntax

PowerShell command Example

2. Manage Retention Policy | Remove Retention Policy

2.1 – Remove Retention Policy from a single a Mailbox (set to Null)

PowerShell command syntax

PowerShell command Example

2.2 – Remove Retention Policy for a Mailbox Retention policy to ALL Office 365 Mailbox’s (Bulk Mode)

PowerShell command Example

3. Manage Retention Policy | Display information about Retention Policy

3.1 – Display the Retention Policy applied to a User Mailbox

PowerShell command syntax

PowerShell command Example

3.2 – Display the Retention Policy applied to all Office 365 users Mailbox’s

PowerShell command Example

4. Retention Policy Tags | Manage Default Retention Policy Tags settings

4.1 – Set the number of days for Deleted items, Tag

PowerShell command syntax

PowerShell command Example

4.2 – Disable Deleted items Tag

PowerShell command Example

4.3 – Set the number of days for Junk Email Tag

PowerShell command syntax

PowerShell command Example

5. Retention Policy Tags | Create NEW Retention Policy Tags

5.1 – Create NEW tag for Sync Issues Folder

PowerShell command syntax

PowerShell command Example

6. Activate Folder Assistant

6.1 – Run the Managed Folder Assistant for a specific Mailbox

PowerShell command syntax

PowerShell command Example

6.2 – Run the Managed Folder Assistant for all Office 365 Mailbox’s (Bulk Mode)

PowerShell command Example

7. Manage Deleted items policy tag

7.1 – Set Deleted items policy for 30 days for specific user

PowerShell command syntax

PowerShell command Example

7.2 – Set Deleted items policy for 30 days for ALL user (Bulk)

PowerShell command Example

7.3 – Display information about Deleted items policy for specific user

PowerShell command syntax

PowerShell command Example

7.4 – Display information about Deleted items policy for ALL users

PowerShell command Example

8. Download Retention Policy PowerShell menu script

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 Retention Policy and Tags 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

Additional reading

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

2 Responses to “Manage Retention Policy and Tags by using PowerShell | Office 365”

  1. Michael McNally Reply

    Great information. Applying a policy is easy but for one thing. You need to know the name of the policy. How can I get a list of available policies? (Once I know their names, finding out what their settings are is also easy!)

Leave a Reply

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