Powershell – Exchange: exporting and deleting items

exchange-2010powershell

How would I safely export data from Exchange 2010 mailboxes to PSTs using New-MailboxExportRequest and have the exported items deleted from the source mailbox? The Powershell cmdlet seems to be missing the -DeleteContent switch which has been part of the Export-Mailbox cmdlet in Exchange 2007.

Using Search-Mailbox -DeleteContent after the MailboxExportRequest has completed seems like a bad idea since I really only want to delete items which have been successfully exported and I could not find any way to obtain a comprehensive list of items processed by New-MailboxExportRequest.

Best Answer

Even so, Search-Mailbox is the way to go forward, please read the following two paraphrases from http://technet.microsoft.com/en-us/library/dd298173%28v=exchg.141%29.aspx:

"The DeleteContent switch specifies that the messages returned by the search be permanently deleted from the source mailbox. When used with the TargetMailbox parameter, messages are copied to the target mailbox and removed from the source mailbox"

"Before you use the DeleteContent switch to delete content, we recommend that you test search parameters by using the LogOnly parameter, as shown in Example 2."

I suggest you check http://technet.microsoft.com/en-us/library/ff459253%28v=exchg.141%29.aspx and (possibly re)write your current script(s accordingly)