Script for Deleted Items
I need a script to search a user's Deleted Items folder and delete items with a Received Date older than 90 days.We have mailbox management policies configured that remove items after 90 days, according to modified date, but we need to immediately free up space for the time being. The mailbox was recently moved from Exchange 2003 to Exchange 2007 and came over with a lot of old deleted messages and want to remove them prior to the 90 days it will take to see the modified date.
May 12th, 2009 7:47pm

Hi there, I would do something like creating a temporary mailbox, export all the e-mails older than 3 monthsthat you want to delete to that mailbox (deleting them from the source mailbox) and then just deleting them from the temporary mailbox. For that you can use the following command: Export-Mailbox <<source_mailbox>> -IncludeFolders "Deleted Items" -TargetFolder DelItems -TargetMailbox <<temp_mailbox>> -IncludeFolders -StartDate "12/02/2009" -DeleteContent -ReportFile C:\DelItemsReport.xml StartDate The StartDate parameter specifies the start date for filtering content that will be exported from the source mailbox. Only items in the mailbox whose date is later than the start date will be exported. When you enter a specific date, use the short date format that is defined in the Regional Options settings that are configured on the local computer. For example, if your computer is configured to use the short date format mm/dd/yyyy, enter 03/01/2006 to specify March 1, 2006. In this case, it will move all the e-mails older than February 12. DeleteAssociatedMessages (dont think you need this one) The DeleteAssociatedMessages parameter specifies that associated messages will be deleted. Associated messages contain hidden data with information about rules, views, and forms. DeleteContent The DeleteContent parameter specifies the option to delete the content from the source mailbox after it has been exported to a folder. The source folder will not be deleted. I havent tried this yet, but Im sure it will work. However, I could have missed something so please test this before you actually run it! Regards, Nuno http://LetsExchange.blogspot.com
Free Windows Admin Tool Kit Click here and download it now
May 12th, 2009 9:02pm

Hello,As Nuno said you can use Export-Mailbox for the same. Just wanted to add few consideration and pre-req for using Export-Mailbox.To run the Export-Mailbox cmdlet, the account you use must be delegated the following: Exchange Server Administrator role and local Administrators group for the target server Full access to the source and target mailboxes For more information about permissions, delegating roles, and the rights that are required to administer Microsoft Exchange Server 2007, see Permission Considerations. To grant full access to a mailbox, use the Add-MailboxPermission cmdlet and specify FullAccess for the AccessRights parameter. You cannot export data from a mailbox in one forest to a mailbox in a different forest. The source and target mailboxes must be in the same forest. You can use the Export-Mailbox cmdlet to export data to either a folder or a .pst file. The source and target mailboxes must be on one of the following: Exchange 2007 server Exchange Server 2003 Service Pack 2 (SP2) (or later versions) server Exchange 2000 Server Service Pack 3 (SP3) (or later versions) server To export data from a .pst file, you must run the Export-Mailbox cmdlet from a 32-bit computer that has the following installed: The 32-bit version of the Exchange management tools Microsoft Office Outlook 2003 SP2 or later versions Note: Microsoft Knowledge Base articles 289999 and 813593 describe a problem with using Outlook 2003 to delete several objects from a folder. You cannot use the Export-Mailbox cmdlet to delete more than 4,000 objects from a folder. To export more objects, you must use Outlook 2007.Arun Kumar | MCSE - 2K3 + Messaging | ITIL-F V3
May 12th, 2009 10:32pm

Nice post Arun.Yes, I think it would make much more sense to just export to a .pst file if it's for deletion, good thinking and nice information!http://LetsExchange.blogspot.com
Free Windows Admin Tool Kit Click here and download it now
May 14th, 2009 5:41pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics