[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 99
  • Last Modified:

Exchange 2010 SP3 - Export all mail from date and going forward

Hi EE,

I'm using:

  $a=Get-Mailbox -Identity "*"
  PS C:\Windows\system32> $a |%{
>> $pst=$_.alias+".pst"
>> New-MailboxImportRequest -Mailbox $_.alias -FilePath "\\\smartware\ExchExport\CurrentEmp\$pst"  -BadItemLimit 100 –AcceptLargeDataLoss –AssociatedMessagesCopyOption copy
>> }

No what would I use to export all mail after 11/30/2014?

Tight deadline by manager.  Any info is much appreciated.
  • 2
  • 2
1 Solution
IvanSystem EngineerCommented:
Hi there,

try something like this, for a single user.

New-MailboxExportRequest -Mailbox "user"  -ContentFilter {(Received -gt 11/30/2014)}  -FilePath "\\\smartware\ExchExport\CurrentEmp\user.pst"

I don't have exchange to try, but I think it should work.

New-MailboxExportRequest -ContentFilter {(Received -lt '04/01/2010') -and (Received -gt '03/01/2010')} -Mailbox "xx" -Name xx -FilePath \\ExServer1\Imports\Xxx.pst

You can use -received or -sent
Then -lt for less than
-gt for greater than
-ge for greater than or equal to

You should be able to just swap import for export, drop the bad item limit and then add the content filter in and the code you already have should work
MacGyver80Senior Systems AdministratorAuthor Commented:
Thank you irweazelwalls.

However, I'm trying to export the entire Mail Database.
Ok so easy way is to use a CSC

Get-mailbox database xxx | get-mailbox | fl display name >c:\mailbox.csv

Take that csv and use in second script

$mailbox = import-csv c:\mailbox.csv

For each ($user in $mailbox) {new -mailboxexportrequest $user.displayname -file path \\server\share\$user.displayname.pst -content filter ....... }

File in what you want as content filter and the above should be mostly right (give or take a  typo or dodgy memory)
MacGyver80Senior Systems AdministratorAuthor Commented:
Worked like a charm. Thank you for the guidance.

Featured Post

Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now