Applies to: Exchange Online, Exchange Server 2016

This cmdlet is available in on-premises Exchange Server 2016 and in the cloud-based service. Some parameters and settings may be exclusive to one environment or the other.

Use the Set-RetentionPolicyTag cmdlet to modify the properties of a retention tag.

For more information about retention tags, see Retention tags and retention policies.

For information about the parameter sets in the Syntax section below, see Exchange cmdlet syntax.

Set-RetentionPolicyTag -Identity <RetentionPolicyTagIdParameter> [-AgeLimitForRetention <EnhancedTimeSpan>] [-MessageClass <String>] [-RetentionAction <MoveToDeletedItems | MoveToFolder | DeleteAndAllowRecovery | PermanentlyDelete | MarkAsPastRetentionLimit | MoveToArchive>] [-RetentionEnabled <$true | $false>] <COMMON PARAMETERS>

Set-RetentionPolicyTag -Mailbox <MailboxIdParameter> [-OptionalInMailbox <RetentionPolicyTagIdParameter[]>] <COMMON PARAMETERS>

COMMON PARAMETERS: [-Comment <String>] [-Confirm [<SwitchParameter>]] [-DomainController <Fqdn>] [-Force <SwitchParameter>] [-LegacyManagedFolder <ELCFolderIdParameter>] [-LocalizedComment <MultiValuedProperty>] [-LocalizedRetentionPolicyTagName <MultiValuedProperty>] [-MustDisplayCommentEnabled <$true | $false>] [-Name <String>] [-RetentionId <Guid>] [-SystemTag <$true | $false>] [-WhatIf [<SwitchParameter>]]

This example changes the comment for the AllUsers-DeletedItems retention policy tag.

Set-RetentionPolicyTag "AllUsers-DeletedItems" -Comment "Items in the Deleted Items folder will be automatically deleted in 120 days"

This example makes optional retention tags available to user Terry Adams using the Mailbox and OptionalInMailbox parameters.

Set-RetentionPolicyTag -Mailbox "Terry Adams" -OptionalInMailbox "ProjectA","ProjectB"

Retention tags are used to apply message retention settings to folders and items in a mailbox.

You need to be assigned permissions before you can run this cmdlet. Although all parameters for this cmdlet are listed in this topic, you may not have access to some parameters if they're not included in the permissions assigned to you. To see what permissions you need, see the "Messaging records management" entry in the Messaging policy and compliance permissions topic.


Parameter Required Type Description




The Identity parameter specifies the name, distinguished name (DN), or GUID of the retention policy tag to be modified.




The Mailbox parameter specifies a mailbox for assigning opt-in tags.

You must use this parameter with the OptionalInMailbox parameter.




The AgeLimitForRetention parameter specifies the age at which retention is enforced on an item. The age limit corresponds to the number of days from the date the item was delivered, or the date an item was created if it wasn't delivered. If this parameter isn't present and the RetentionEnabled parameter is set to $true, an error is returned.




The Comment parameter specifies a comment for the retention policy tag.




The Confirm switch specifies whether to show or hide the confirmation prompt. How this switch affects the cmdlet depends on if the cmdlet requires confirmation before proceeding.

  • Destructive cmdlets (for example, Remove-* cmdlets) have a built-in pause that forces you to acknowledge the command before proceeding. For these cmdlets, you can skip the confirmation prompt by using this exact syntax: -Confirm:$false.

  • Most other cmdlets (for example, New-* and Set-* cmdlets) don't have a built-in pause. For these cmdlets, specifying the Confirm switch without a value introduces a pause that forces you acknowledge the command before proceeding.




This parameter is available only in on-premises Exchange 2016.

The DomainController parameter specifies the domain controller that's used by this cmdlet to read data from or write data to Active Directory. You identify the domain controller by its fully qualified domain name (FQDN). For example,




The Force switch overrides the confirmation prompt displayed by the cmdlet when you use the RetentionId parameter.




The LegacyManagedFolder parameter specifies the name of a managed folder. The retention tag is created by using retention settings from the managed folder and its managed content settings. You can use this parameter to create retention tags based on existing managed folders to migrate users from managed folder mailbox policies to retention policies.




The LocalizedComment parameter specifies the localized comment and language for the retention policy tag. This comment is displayed in Microsoft Outlook based on the user's locale.




The LocalizedRetentionPolicyTagName parameter specifies a localized name for the retention policy tag. This name is displayed in Outlook based on the user's locale.




The MessageClass parameter specifies the message type to which the tag applies. If not specified, the default value is set to *.

With the exception of a default policy tag (DPT) for voicemail, Exchange doesn't support retention tags for different message types. Only tags with a MessageClass of * are supported, and they apply to all message types.

To create a DPT for voice mail messages, set the MessageClass parameter to voicemail and the Type parameter to All.

A DPT for voice mail messages applies only to Microsoft Exchange Unified Messaging voice mail messages (identified by the PR_MESSAGE_CLASS MAPI property value IPM.Note.Microsoft.Voicemail*).




The MustDisplayCommentEnabled parameter specifies whether the comment can be hidden. The default value is $true.




The Name parameter specifies the name of the retention policy tag.




The OptionalInMailbox parameter is used with the Mailbox parameter to specify opt-in retention tags available to the mailbox.




The RetentionAction parameter specifies one of the following actions:

  • MarkAsPastRetentionLimit   This action isn't available for retention tags. If you specify this action for a retention tag, messages that have the tag applied aren't deleted or marked as past the retention limit.

  • MoveToFolder   This action isn't available for retention tags. You can't specify this action for a retention tag.

  • MoveToDeletedItems   This action isn't available for retention tags. If you specify this action for a retention tag, messages that have the tag applied aren't deleted or marked as past the retention limit.

  • DeleteAndAllowRecovery   This action deletes a message and allows recovery from the Recoverable Items folder.

  • PermanentlyDelete   This action permanently deletes a message. A message that has been permanently deleted can't be recovered by using the Recoverable Items folder. Permanently deleted messages aren't returned in a Discovery search, unless litigation hold is enabled for the mailbox.

  • MoveToArchive   This action moves a message to the user's archive mailbox.

If this parameter isn't present and the RetentionEnabled parameter is set to $true, an error is returned.




The RetentionEnabled parameter specifies whether the tag is enabled. When set to $false, the tag is disabled, and no retention action is taken on messages that have the tag applied.

Messages with a disabled tag are still considered tagged, so any default policy tags in the user's retention policy aren't applied to such messages.

When you set the RetentionEnabled parameter to $false, the retention period for the tag is shown as Never. Users may apply this tag to items that they want to indicate should never be deleted or should never be moved to the archive. Enabling the tag later may result in unintentional deletion or archiving of items. To avoid this situation, if a retention policy is disabled temporarily, it may be advisable to change the name of that tag so that users are discouraged from using it, such as DISABLED_<Original Name>.




The RetentionId parameter specifies an alternate tag ID to ensure the retention tag found on mailbox items tagged in one Exchange organization matches the tag when the mailbox is moved to another Exchange organization (for example, in a cross-forest deployment or in a cross-premises deployment, when a mailbox is moved from an on-premises Exchange server to the cloud, or a cloud-based mailbox is moved to an on-premises Exchange server).

It's not ordinarily required to specify or modify the RetentionId parameter for a retention tag. The parameter is populated automatically by <scriptname> when importing retention tags in a cross-forest or cross-premises deployment.




The SystemTag parameter specifies whether the retention policy tag is created for internal Exchange functionality.




The WhatIf switch simulates the actions of the command. You can use this switch to view the changes that would occur without actually applying those changes. You don't need to specify a value with this switch.

To see the input types that this cmdlet accepts, see Cmdlet Input and Output Types. If the Input Type field for a cmdlet is blank, the cmdlet doesn’t accept input data.

To see the return types, which are also known as output types, that this cmdlet accepts, see Cmdlet Input and Output Types. If the Output Type field is blank, the cmdlet doesn’t return data.