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?


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" 

or only for this mailbox:

if($succeeded)    {
    $Name= $provisioningHandler.UserSpecifiedParameters["Name"] 
    if($provisioningHandler.UserSpecifiedParameters["RetentionPolicy"] -eq $null){ 
    Set-Mailbox -Identity $Name -RetentionPolicy "foo" 
  • I was fearing this. The extension agent looks better than a scheduled script, though. – Massimo Dec 6 '12 at 14:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.