The Hot Blog

In hot blog, we blog hotfix right!

How to apply Retention Policies to all mailboxes

How to apply Retention Policies to all mailboxes

  • Comments 3
  • Likes

Summary

You can use retention policies to group one or more retention tags and apply them to mailboxes to enforce message retention settings. In some scenario, you may need create custom retention policy and apply to all users automatically.

Generally, to create custom retention policy and apply it to all mailboxes in the organization, you can follow the steps below:

    1.       Connect to Office 365 service through remote PowerShell.

      http://help.outlook.com/en-us/140/cc952755.aspx

        2.       In PowerShell run Enable-OrganizationCustomization enable customization.

          3.       Create Retention Policy Tag by using New-RetentionPolicyTag similar to below:

            New-RetentionPolicyTag -Name "Darkaura-Default-Archive-All-3-Months" -RetentionAction movetoarchive -AgeLimitForRetention 90 -Type all -Comment "All mails are archived after 90 days. Users without archives are not affected."

              4.       Create a Retention Policy to include the tag

                New-RetentionPolicy -Name "DarkAura Archive" -RetentionPolicytagLinks "Darkaura-Default-Archive-All-3-Months"

                  5.       Apply the Retention Policy to all the mailboxes:

                   

                  Get-Mailbox | Set-mailbox -RetentionPolicy "Darkaura Archive"

                    6.       Following command can be used to verify whether the retention policy has been applied to all the mailboxes:

                      Get-Mailbox -ResultSize Unlimited | select Alias, RetentionPolicy

                        7.       Create the script.

                        a.      Open Notepad.

                        b.      Copy and paste the text that is between the # signs to Notepad.

                            ##############################################################

                            Get-Mailbox -ResultSize Unlimited | select Alias |export-csv C:\users.csv

                            $Users = Import-csv -path "C:\users.csv"

                            $users | ForEach-Object

                            {

                                $alias = $_.Alias

                                Start-ManagedFolderAssistant $alias

                            }

                            ##############################################################

                              c.       On the File menu, click Save As.

                              d.      In the Save As dialog box, click All Files (*.*) in the Save as type box, type Start_MFA.ps1 in the File name box, and then save the file to the desktop.

                                8.       In PowerShell, run the script.

                                  9.       Drag the .ps1 file from the desktop to the PowerShell window. The path is automatically displayed in the PowerShell window.

                                    10.   To run the script, press ENTER.

                                      11.   Login with any mailbox account in OWA .

                                        a.      Click Options, click See all Options.

                                        b.      Click Organize E-Mail, click Retention Policies.

                                        c.       Verify the custom Retention Policy is applied:

                                          More Information

                                          Set Up and Manage Retention Policies in Exchange Online with Windows PowerShell

                                          http://help.outlook.com/en-us/beta/gg271153.aspx#nextsteps

                                          Apply Retention Policies and Archive Policies to Your Messages

                                          http://help.outlook.com/en-us/beta/cc950504.aspx

                                          Applies To/Requirements

                                          Office 365 for Enterprise

                                          Exchange Server 2010 SP2

                                          Comments
                                          • Scenario: Some mailboxes have different policies already and you only want to apply a new policy to mailboxes without an existing policy.

                                            What would the command to apply "Darkaura Archive" be in this case?

                                          • Never mind I think I figured it out:

                                            Get-Mailbox -ResultSize unlimited -Filter {(RetentionPolicy -eq $null) -and (Name -NotLike "DiscoverySearch*")} | Set-Mailbox -RetentionPolicy "Darkaura Archive"

                                          • We have set Retention policy on 2007 , 2010 and 2013 we have these version setup in our env all 3 are not connected .... question is can i set retention policy as default as if anyone create a new mailbox it should auto apply the retention policy ... can you please help on setting or any script which runs daily and apply any new user ?

                                          Your comment has been posted.   Close
                                          Thank you, your comment requires moderation so it may take a while to appear.   Close
                                          Leave a Comment