有这个需求,是因为特大邮件》50G的用户,如果一定次导出为PST,则往往放在OUTLOOK里会读写失败。
于是,分期分批的导出再删除,是一个可行的办法。
关键命令:
I recently found myself looking for a way to move old messages to .pst in order to reclaim disk space. Things have changed a little since the GUI days of Exmerge.exe and the Export-Mailbox cmdlet of Exchange 2007. They’ve been replaced with New-MailboxExportRequest.
The good news is that the -ContentFilter switch is pretty robust. To export all messages (in all folders) that were delivered prior to May 1st, 2010 I used the following syntax:
New-MailboxExportRequest -Mailbox Barry -IsArchive -ContentFilter {(Received -lt ’05/01/2010′)} –FilePath “\\barryserver\mailboxexports\barry.pst”
Then to remove the messages that were just exported I ran:
Search-Mailbox Barry -SearchQuery “Received:< $(’05/01/2010 00:00:00′)” -DeleteContent
A few things to point out…
-IsArchive: This switch is telling exchange to grab everything in the mailbox AND the on-line archive. If you’re not using the on-line archive slap yourself, than feel free to remove the switch. You won’t need this with Search-Mailbox because it will check the archive by default. If you want to ignore the archive then the appropriate switch is: DoNotIncludeArchive
Received -lt: lt stands for less than, you can also use -le (less than or equal too) or -ge (greater than or equal to, you get the picture…). I don’t know why the lt switch wont work with the Search-Mailbox command, but it just doesn’t so us the ‘<’ symbol.
-FilePath: This MUST be a UNC path on the local network, no local drives. You also need add full security permissions to the ExchangeTrustedSubsystem account for the folder you are copying to.
Last but not least run a manual defrag of the exchange database to recover the disk space. here’s a good article on that process:
I recommend you look at the following pages for more info about Export and Import Requests in powershell:
- Import/Export Mailbox improvements in Exchange 2010 Service Pack 1 (Part 2): (Part 1 is a must for setting up powershell permissions for first time users)
- Date range exports with New-MailboxExportRequest: (Great article, but make sure you read through the comments!)
If you have any questions feel free to ask.