How to create a default retention policy in Exchange 2010

exchangeexchange-2010

I want to create a retention policy in Exchange 2010 (SP2), apply it to all existing mailboxes (and this is easy), and then have it automatically applied to all new mailboxes.

Is this possible?
How?

Best Answer

You can write a script and run it daily (get a list of all mailboxes without a retention policy) or use a cmdlet extension agent to detect when mailbox is created and automatically assign a rentention policy (don't have access to exchange 2010 atm so can't really test it):

<?xml version="1.0" encoding="utf-8" ?>
<Configuration version="1.0">
<Feature Name="MailboxProvisioning" Cmdlets="new-mailbox">
<ApiCall Name="OnComplete">
    if($succeeded)    {
        $mbx = get-mailbox | where{!$_.RetentionPolicy} 
        foreach($mb in $mbx){
            Set-Mailbox –RetentionPolicy "foo" 
        }
    }
</ApiCall>
</Feature>
</Configuration>

or only for this mailbox:

if($succeeded)    {
    $Name= $provisioningHandler.UserSpecifiedParameters["Name"] 
    if($provisioningHandler.UserSpecifiedParameters["RetentionPolicy"] -eq $null){ 
    Set-Mailbox -Identity $Name -RetentionPolicy "foo" 
    }
}
Related Topic