Use Exchange Management Shell Scripts for Managed Folders


Applies to: Exchange Server 2010 SP3, Exchange Server 2010 SP2

You can use Shell cmdlets and scripts to manage messaging records management (MRM) in Microsoft Exchange Server 2010. We recommend that you test MRM features in a non-production environment first. When you're ready to implement MRM in production, you can use the same scripts in your production environment to accurately and consistently replicate managed folders, managed content settings, and managed folder mailbox policies.


Managed custom folders are a premium feature of MRM. Each mailbox that has managed custom folders requires an Exchange Server Enterprise client access license (CAL). Mailboxes with policies that include managed custom folders require an Exchange Server Enterprise CAL.

Use the Shell to manage managed folders

You need to be assigned permissions before you can perform this procedure. To see what permissions you need, see the "Messaging records management" entry in the Messaging Policy and Compliance Permissions topic.

  1. Create a script by entering Shell commands in a text editor, as shown in the sample script that follows.

  2. Save the text file for the script with the .ps1 file extension (for example, MRM_Sample_Script.ps1).

  3. At the command prompt in the Shell, enter the path and file name of the script (for example, C:\Scripts\MRM_Sample_Script.ps1, or .\MRM_Sample_Script.ps1 for a script in the working directory).

The following is a sample script for MRM. For an explanation of the actions performed, see the comments within the script.

# MRM_Sample_Script.ps1

# This script demonstrates the fundamentals of performing messaging records management by running scripts in the Exchange Management Shell.

# Create a new managed custom folder.
New-ManagedFolder -Name "Important E-mail" -FolderName "Business Folder A" 

# Create a variable, \"$age,\" to use in the next command.
$age = New-TimeSpan -Day 30

# Create managed content settings for the new managed custom folder that delete items after 30 days.
New-ManagedContentSettings -Name "Retention settings for Business Folder A" -FolderName "Business Folder A" -MessageClass VoiceMail -RetentionEnabled:$true -AgeLimitForRetention $Age -RetentionAction PermanentlyDelete

# Create a managed folder mailbox policy.
New-ManagedFolderMailboxPolicy -Name "Business Folder A" -ManagedFolderLinks "Important E-mail"

# Apply the managed folder mailbox policy to a mailbox.
Set-Mailbox -Identity Administrator -ManagedFolderMailboxPolicy "Business Folder A"

# Schedule the Managed Folder Assistant to run the entire week.
$ServerName= cmd /c echo %computername%
Set-MailboxServer -ID $ServerName -ManagedFolderAssistantSchedule "Sun.12:00-Sun.11:00"

# Start the Managed Folder Assistant. 

 © 2010 Microsoft Corporation. All rights reserved.