Exchange Mailbox Retention Policy Cleanup

Exchange Server LogoExchange Server and Exchange Online use retention policies to group retention tags. A retention tag defines how and when Exchange should delete a mailbox object automatically or move it to the archive mailbox. Most of the time, you think of emails when talking about Exchange mailbox objects. We stay with emails for this article.

Sometimes, retention policies show unexpected behavior, and you want to clean up the retention information from a mailbox.

We need to know the basics to understand how to clean up the policies.

Policy tags: Default tags and Personal tags

Default tags and personal tags specify what the Managed Folder Assistant should do with the emails. You assign one or more retention tags to a retention policy. You then assign the retention policy to a mailbox.

Default tags are assigned to the whole mailbox. End users can set personal tags to folders or single elements. The third tag, the default folder tag, is primarily used in delete policies.

Retention policy

A retention policy can have one or more default or personal retention tags. A single mailbox can only have one policy assigned.

The following screenshot shows a user’s default retention policies, arbitration mailboxes, and two additional test policies.

Screenshot showing the Exchange rention policies

If you want to know more about retention tags and policies, I recommend reading the Microsoft documentation.

Cleaning up retention tags in an Exchange mailbox

But what exactly would we like to remove from a mailbox?

  • Policy Tags and Personal Policy Tags

Removing a retention policy from a mailbox is simple. You replace the assigned policy with another policy, or you set the attribute to $null to remove the policy assignment. Removing or replacing a retention policy does not remove personal tags assigned to folders by the user.

If you want to remove a personal tag from a mailbox, Microsoft has the answer for you:

  • Purge the tag from the Exchange Organization

But what if other users in your Exchange organization also use this personal tag? Deleting a personal retention tag from the Exchange Organization will remove this tag from all mailboxes.

Solution

Supposed you have a delete policy (default tag) set on a mailbox. Also, you allow the user to exclude folders with a personal tag. Removing this personal tag for all mailboxes will lead to significant calls for your helpdesk because the Managed Folder Assistant will delete all emails from all mailboxes. Not to say that you must restore the emails.

But help is on the way. The tool RemovePersonalRetentionTag helps you clean up retention tags.

  • GitHub Link

This tool removes one or more personal tags from the folders in a single mailbox without deleting the tag from your Exchange Organization.

You need impersonation rights for the mailbox you want to clean up. And basic authentication needs to be enabled for Exchange Online if the mailbox is an EXO mailbox. The code now uses Exchange Web Services to remove retention tags.

If you want to remove all personal tags from a mailbox, it is simple:

RemovePersonalRetentionTag.exe -mailbox "user@example.com" -impersonate

You must know the retention tag id if you want to remove a specific tag.

First, grab a list of the retention tag ids in your environment:

  • Execute in an Exchange (Online) PowerShell session
Get-RetentionPolicyTag -Types Personal | Select Name,RetentionId | ft -a
Screenshot Exchange Management Shell
  • Remove a single tag
RemovePersonalRetentionTag.exe -mailbox "user@example.com" -impersonate -retentionid "a7966968-dadf-4df7-ae87-4482686b4634"
  • Or multiple tags
RemovePersonalRetentionTag.exe -mailbox "user@example.com" -impersonate -retentionid "a7966968-dadf-4df7-ae87-4482686b4634, 414c6a14-3ed5-432e-9edb-c6620a8278f0"

This tool is useful when personal MRM policies are assigned to system folders like “Yammer.”

%d Bloggern gefällt das: