Link to home
Start Free TrialLog in
Avatar of TechMan4Ever
TechMan4Ever

asked on

In Exchange 2010 PowerShell I need to move emails older than X date into a PST file.

Hi,

I have an Exchange 2010 with online archiving enabled. I need to clean up the online archives, so I need to export all emails that are older than X date into a PST file, it needs to move the emails into a PST file. I don't care if this is done per user or everyone at once. I would like to split this into multiple PST files once it gets to 2GB size to automate this process a bit as my archive file is over 1TB. Any help is greatly appreciated.

Thank you,
Avatar of Systech Admin
Systech Admin
Flag of India image

Use the below command

New-MailboxExportRequest -ContentFilter {(Received -lt 'Date') -and (Received -gt 'Date')} -Mailbox "Mailboxname" -Name FileName -FilePath \\ExServer1\Imports\Mailboxname.pst
Avatar of TechMan4Ever
TechMan4Ever

ASKER

I believe this command copies data to a PST file and leave the original where it is, is that correct? I need to MOVE it, once in a PST file the original needs to be deleted.

Thanks,
ASKER CERTIFIED SOLUTION
Avatar of Systech Admin
Systech Admin
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you, now how would i do it if I wanted stuff older than 1/1/2010 to be moved over... which of the switches would I use, I believe this is from to? I just want older than.

Thanks,
you will need to mention the dates.. here  {(Received -lt 'Date') -and (Received -gt 'Date')}
New-MailboxExportRequest doesn't have a -DeleteContent switch in either 2010 or 2013.  That's a function of Export-Mailbox which was the 2007 utility.  I did here that 2010 RTM or other early SP level had an Export-Mailbox command, but I jumped in at SP2 so I'm not sure.

If I'm right there's really no way to get it to do exactly what you want.  Search-Mailbox does have a -DeleteContent parameter, so  you might be able to use it to move the messages to a discovery mailbox then use New-MailboxExportRequest to target the specific folders in the discovery mailbox and export to a PST.

One other thing if you use the filter format be careful how you specify the dates.  Usually I add 1 date to the upper boundary, for example if I want mail before 1/1/2014 I would use -lt 1/2/2014.  If I want mail after 1/1/2013 I will use -ge 1/1/2013, which accommodates the edge case where a message was received right at midnight.  It's petty but it's thorough.