Manage Retention Policy and Tags by using PowerShell | Office 365 5/5 (1)

5 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 mail before the mail 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

In case that you are a novice in the PowerShell environment, you can use the following link to get more information about the “first steps” such as: downloading the required PowerShell
software components, how to use the PowerShell console, running a PowerShell script, etc.

Read more
Link Table
PowerShell Naming Conventions & general information

If you want to get more information about the Naming Conventions that we use for this article and get some general tips about: how to work with the PowerShell, read the article: Help and additional information – o365info.com PowerShell articles

Create remote PowerShell session

Before we can use the required PowerShell commands, we need to download and install the Office 365 cmdlets + create remote PowerShell session to Office 365 or Exchange Online. If you need more information about how to create a remote PowerShell session read the following articles: Part 2: Connect to Office 365 by using Remote PowerShell and Part 3: Connect to Exchange Online by using Remote PowerShell

How to use a PowerShell script

Most of the PowerShell articles include a PowerShell script that simplifies the use of the PowerShell commands. If you want to get more information about – How to use a PowerShell script, read the article: Connect to Office 365 and Exchange Online using a script

PowerShell command and Script languish in more details

If you are new to the PowerShell world, you can read more information about PowerShell in Office 365 environment in the article: The Power of PowerShell

1. 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. 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 Syntax

3. 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 Syntax

4. 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 Syntax

4.3 – Set the number of days for Junk Email Tag

PowerShell command Syntax

PowerShell command Example

5. 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 Syntax

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 Syntax

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 Syntax

8. Download Retention Policy PowerShell menu script

For your convenience, I have “Wrapped” all the PowerShell commands that were reviewed in a PowerShell Script named:
Retention-Policy.ps1
You are welcome to download the script and use it.

download-button-02.png

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
Summary
Article Name
Manage Retention Policy and Tags by using PowerShell | Office 365
Description
In the current article, we will review how to use PowerShell commands for managing Retention Policy in Exchange Online environment.
Author
Publisher Name
o365info.com
Publisher Logo
Print Friendly

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 *