Get started Bring yourself up to speed with our introductory content.

Exchange Server 2010 retention tag creation basics

Creating retention tags and policies in Exchange 2010 is an elaborate undertaking. Luckily it's also a logical process. This tip outlines the EMS commands you must use, along with how to add tags to retention policies.

The first step in managing retention settings in Exchange Server 2010 is to create one or more retention tags. Creating a retention tag and policy is a fairly elaborate process that uses the new RetentionPolicyTag command in Exchange Management Shell (EMS). This tip explains how to create and add retention tags and policies in Exchange 2010.

There are several parameters involved in creating a retention tag, including:

  • Tag name: The tag name isn't bound to a specific attribute, but is actually listed in quotation marks immediately after the New-RetentionPolicyTag command.
  • Type: This is the retention tag type as well as the name of a default folder -- either All (default policy tag) or Personal (personal tag).
  • Comment: This is a description of the retention tag.
  • RetentionEnabled: This controls whether or not the retention tag is active.
  • AgeForRetention: This denotes the retention period, specified in days.
  • RetentionAction: This denotes what happens to data when the retention period ends.

To create a personal retention tag named ImportantStuff, for example, which archives messages after five years, use the following command:

New-RetentionPolicyTag "ImportantStuff" –Type Personal –Comment 'Important Message Archive After Five Years' –RetentionEnabled $True –AgeForRetention 1825 –RetentionAction MoveToArchive

Creating a retention policy in Exchange Server 2010

After you create one or more retention tags, you need to create a retention policy that incorporates the tags. To create a retention policy, use the New-RetentionPolicy command in EMS, followed by the name of your policy, the RetentionPolicyTagLinks attribute and the names of the tags you want to include.

For example, if you wanted to create a retention policy named ContosoRetentionPolicy and include the ImportantStuff tag that you created earlier, you would use this command:

New-RetentionPolicy "ContosoRetentionPolicy" –RetentionPolicyTagLinks "ImportantStuff"

You can also include multiple retention tags in a retention policy. To do so, enclose the name of each retention tag in quotation marks and separate each with a comma.

Applying retention policies in Exchange Server 2010

To apply a retention policy to users' mailboxes, you'll again create a command in EMS. With this command, you only need to provide Exchange with the name of the mailbox and the name of the retention policy you want to assign. For example, you would use the following command to assign the previously created ContosoRetentionPolicy to User1.

Set-Mailbox "User1" –RetentionPolicy "ContosoRetentionPolicy"

There are also some variations of this technique that you can use to either assign a retention policy to a distribution group or to change the retention policy that's assigned to a mailbox. Both actions require you to use multiple commands -- which are separated by the pipe symbol (|).

Using the pipe symbol (|) in EMS instructs Exchange server to take the output from one command and add it to the next command. For example, here's a command that changes a mailbox's retention policy:

$OldPolicy=(Get-RetentionPolicy "ContosoRetentionPolicy"}.DistinguishedName Get-Mailbox –Filter {RetentionPolicy –EQ $ContosoRetentionPolicy} –Resultsize Unlimited | Set-MailboxRetentionPolicy "NewPolicy"

The command defines a variable called $OldPolicy, which contains the name of every mailbox to which the ContosoRetentionPolicy has been assigned. Then the Get-Mailbox command retrieves those mailboxes and pipes the results into the same Set-RetentionPolicy command.

This shows how you can change the retention policy for a large group of users. If you only want to set the policy for a single user, you would use the Set-Mailbox command.

Retention policies for Exchange 2010 distribution groups

To assign the policy that we created earlier -- ContosoRetentionPolicy – to a distribution group named Finance, you would use the following command:

Get-DistributionGroupMember –Identity "Finance" | Set-Mailbox –RetentionPolicy "ContosoRetentionPolicy"

This is a compound command that uses the Get-DistributionGroupMember syntax to retrieve mailbox names within the distribution group. Results are then piped into the Set-Mailbox command and applies the retention policy.

The command only applies the retention policy to the group's current members. However, if changes are made to the distribution group's membership, Exchange does not automatically reapply the retention policy to compensate for those changes.

If you need to apply a retention policy to a distribution group, schedule the command to run on a periodic basis. If you need to add a tag after the fact, it is possible to add a retention tag to a retention policy that's already in use.

About the author: Brien M. Posey, MCSE, is a seven-time recipient of Microsoft's Most Valuable Professional (MVP) award for his work with Exchange Server, Windows Server, Internet Information Services (IIS), and File Systems and Storage. Brien has served as CIO for a nationwide chain of hospitals and was once responsible for the Department of Information Management at Fort Knox. As a freelance technical writer, Brien has written for Microsoft, TechTarget, CNET, ZDNet, MSD2D, Relevant Technologies and other technology companies. You can visit Brien's personal website at

Do you have comments on this tip? Let us know.

Dig Deeper on Exchange Server setup and troubleshooting