Microsoft (Office 365) retention policies make it easy for the user and administrator to clean up and archive items in a user’s mailbox on Exchange Online. Retention policies allow to automatically assign some trigger action for an item after a certain period (for instance, move the item to the archive mailbox or delete it permanently). Microsoft 365 retention policies can be used to automatically remove email items older than a specified date from a user’s mailbox. By default, retention policies apply to the Deleted Items and Junk Mail folders to automatically remove items that are older than 30 days.
Note. You can also check our article Configuring Office 365 Archiving Policy.
Applying Retention and Archive Policies in Outlook Web App
By default, retention policies do not apply to other folders in the inbox (except for Deleted Items and Junk). However, the user can manually set retention tags for certain folders. For example, a user wants to automatically delete old messages from the Newsletter folder after one year. He can manually set the Retention/Archiving Tags for email items in Office 365 mailbox.
- Sign in to your Microsoft (Office) 365 account;
- Select Outlook in the App Launcher;
- In the interface of your mailbox, right-click on the folder or email message for which you want to change Retention/Archive settings;
- Select an archive policy or retention label from the list. Keep in mind that by default the Retention policy settings are inherited from the parent folder (Use parent folder policy);
If none of the default retention policies suits you, then create your own custom retention policies with the parameters you need:
- Select Settings > Mail > Retention policies;
- Click the Add new policy button and create your own custom retention policy with the parameters you need;
- After that, you can apply your custom retention policy to the required items in the Inbox folder of the Office 365 mailbox.
Note. Note that Exchange Online calendar items are not retained.
How to Create a Microsoft 365 Retention Policy using Microsoft 365 Admin Center?
The Microsoft (Office) 365 administrator can create custom Retention tags and Retention Policies and assign them to user mailboxes.
- To to use some Retention Policies, you need to enable users’ archive mailboxes. Go to the Microsoft 365 Admin Center;
- Select the user mailboxes for which you want to enable archive mailbox, go to the Mail tab, and click Edit Exchange Properties;
- Go to the mailbox feature tab and enable the Archiving option;
- Now go to the Exchange Admin Center > Compliance manager > Retention tags;
- Create a new Retention Tag with the required parameters (+ > select applied automatically to the entire mailbox). For example, we have created a tag named “3 Year move to archive”, Retention action > Move to archive; Retention period > when the item reaches the following age (in days) > 1095;
- Then go to Exchange Admin Center > Compliance Management > Retention Policies. Press the + button;
- Name the Retention Policy and add retention tags you want to apply to user mailboxes;
- Then you need to assign the policy to User Mailboxes. Go to Exchange Admin Center > Recipients > Mailboxes. Select the mailboxes for which you want to apply policies, click More options > Update for Retention Policy. In the drop-down list of the Bulk Assign Retention Policy form, select a new retention policy you created earlier;
Managing Retention Policies in Microsoft 365 with PowerShell
You can manage your Microsoft 365 retention policies using PowerShell. To do this, install the Exchange Online PowerShell v2 (EXO V2):
Import-Module ExchangeOnlineManagement
Connect to the Microsoft 365 Security and Compliance Center:
Connect-IPPSSession -UserPrincipalName admin@theitbros.com
To create a new retention tag, use the New-ComplianceTag cmdlet:
New-ComplianceTag -Name "WORD docs" -RetentionAction Keep -RetentionDuration 730 -RetentionType ModificationAgeInDays
In this example, we have set three retention tag options:
- RetentionAction — specifies the action for the label (Delete, Keep, KeepAndDelete);
- RetentionType — specifies how to calculate the retention duration from the content creation date, tagged date, or last modification date (CreationAgeInDays, EventAgeInDays, TaggedAgeInDays, ModificationAgeInDays);
- RetentionDuration — the number of days to retain the content (2 years or 730 days in this case).
You can list your custom retention tags (labels) with the command:
Get-ComplianceTag|Format-Table
In order to create a new retention policy for Exchange Online mailboxes, use the New-RetentionCompliancePolicy cmdlet:
New-RetentionCompliancePolicy -Name "Word Docs" -ExchangeLocation All
If you need to create a Retention policy only for certain user mailboxes:
New-RetentionCompliancePolicy -Name "Word Docs" -ExchangeLocation "j.brion@theitbros.com","m.berg@theitbros.com"
Now you can create a retention compliance rule that links your retention tag and retention policy:
New-RetentionComplianceRule -Policy "Word Docs" -ApplyComplianceTag "Word docs" -ContentMatchQuery “filetype:docx”
In this case, in the ContentMatchQuery parameter, we have specified a rule or query that will be used to filter the elements to be saved. The Keyword Query Language (KQL) syntax is used in a query.