How to Export all Email from Exchange Server 2010 for a Specified Time Period

Hi.  I need to export all email for all users from our 2010 Exchange Server (about 200) for a two month period (11/21/2016 to 02/01/2017) to be ingested by Intermedia for onpremise archiving.   I'm not a power shell guru and I need help.  I've looked at several scripts, but was left more confused than not.  

 Would it be something like this?  

 Get-Mailbox -Database DB1 | Export-Mailbox  -StartDate "11/21/2016" -EndDate "02/01/2017" - \\10.10.10.10\EmailBackup \.pst

 And would that include all their email even if they've moved it into folders that they created within their mailbox?

 Please assist.  Thank you very much!
skbryanAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Patrick BogersDatacenter platform engineer LindowsCommented:
Hi,

I think more like

$Export=.\mailboxes.txt
 foreach ($i in ($Export)) {New-MailboxExportRequest -ContentFilter {(Received -lt '21/11/2016') -and (Received -gt '02/01/2017')} -Mailbox $i -Filepath "\\10.10.10.10\EmailBackup\$($i).pst" }

This Will export all mailboxes to their OWN pst file. (Incl all subfolders)

Cheers
0
skbryanAuthor Commented:
Thank you very much for your reply.  I ran the script and this is what I got:

Windows PowerShell
Copyright (C) 2009 Microsoft Corporation. All rights reserved.

PS N:\> $Export=.\mailboxes.txt
The term '.\mailboxes.txt' is not recognized as the name of a cmdlet, function, scri
 the spelling of the name, or if a path was included, verify that the path is correc
At line:1 char:24
+ $Export=.\mailboxes.txt <<<<
    + CategoryInfo          : ObjectNotFound: (.\mailboxes.txt:String) [], CommandNo
    + FullyQualifiedErrorId : CommandNotFoundException

PS N:\>   foreach ($i in ($Export)) {New-MailboxExportRequest -ContentFilter {(Recei
 -gt '02/01/2017')} -Mailbox $i -Filepath "\\10.10.1.35\EmailBackup\$($i).pst" }

Also, will this pick up all sent messages as well, correct?  Thank you very much for your help!!!!!
0
Patrick BogersDatacenter platform engineer LindowsCommented:
Hi

In the local dir i expect a file called mailboxes.txt in which i expect to have all mailboxes to be exported.

Yes this included sent items, deleted items, custom dirs everything.
0
Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

skbryanAuthor Commented:
I know we are close!  

PS N:\> $Export=.\mailboxes.txt foreach ($i in ($Export)) {New-MailboxExportRequest -ContentFilter {(Received -lt '21/11
/2016') -and (Received -gt '02/01/2017')} -Mailbox $i -Filepath "\\10.10.1.35\EmailBackup\$($i).pst" }
Unexpected token 'in' in expression or statement.
At line:1 char:39
+ $Export=.\mailboxes.txt foreach ($i in <<<<  ($Export)) {New-MailboxExportRequest -ContentFilter {(Received -lt '21/1
1/2016') -and (Received -gt '02/01/2017')} -Mailbox $i -Filepath "\\10.10.1.35\EmailBackup\$($i).pst" }
    + CategoryInfo          : ParserError: (in:String) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : UnexpectedToken

PS N:\>

in notepad, do I list them on each line, like:
rsmith
lsmith
rjones
etc.

Thank you very much!
0
Patrick BogersDatacenter platform engineer LindowsCommented:
In notepad Yes thats the way, we work with the displayname.
You are trying two PS commands in one line, this is not working.

Either you put the two lines in a file and call it xxxx.ps1 and run this from PS.
Or you open PS ISE and run multiple lines from there at Once.
0
skbryanAuthor Commented:
Here is what I got:

PS N:\> $Export=.\mailboxes.txt
PS N:\> foreach ($i in ($Export)) {New-MailboxExportRequest -ContentFilter {(Received -lt '21/11/2016') -and (Received -
gt '02/01/2017')} -Mailbox $i -Filepath "\\10.10.1.35\EmailBackup\$($i).pst" }
New-MailboxExportRequest : Cannot validate argument on parameter 'Mailbox'. The argument is null. Supply a non-null arg
ument and try the command again.
At line:1 char:139
+ foreach ($i in ($Export)) {New-MailboxExportRequest -ContentFilter {(Received -lt '21/11/2016') -and (Received -gt '0
2/01/2017')} -Mailbox <<<<  $i -Filepath "\\10.10.1.35\EmailBackup\$($i).pst" }
    + CategoryInfo          : InvalidData: (:) [New-MailboxExportRequest], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.Exchange.Management.RecipientTasks.NewMailbox
   ExportRequest

Ran the first command just fine.  On the second one, not so much.  Thank you.
0
skbryanAuthor Commented:
we are running exchange 2010 SP3 Rollup 7, Version: 14.03.0210.002

Thank you.
0
Patrick BogersDatacenter platform engineer LindowsCommented:
Which version PS?
$PSVersionTable
0
skbryanAuthor Commented:
0
skbryanAuthor Commented:
PS N:\> $PSVersionTable.PSVersion

Major  Minor  Build  Revision
-----  -----  -----  --------
2      0      -1     -1
0
skbryanAuthor Commented:
If I replace the command ($Export) with (Get-Mailbox), it appears to want to try and work - I now see a queued list.

foreach ($i in (Get-Mailbox)) { New-MailboxExportRequest -ContentFilter {(Received -lt '11/21/2016') -and (Received -gt '02/01/2017')} -Mailbox $i -Filepath "\\10.10.1.35\EmailBackup\$($i).pst" }

I wonder what I will get or if it will work. . .
0
Patrick BogersDatacenter platform engineer LindowsCommented:
Nice find.
I strongly recommend upgrading powershell to 3 or 4.

Awaiting outcome
0
skbryanAuthor Commented:
It appears to be backing up the email boxes s l o w l y, probably because I am in a hurry.  Don't want to open one yet because I don't want to mess anything up.  

If I upgrade Powershell, will it still be compatible with my version of Exchange?  (I understand that some of the commands may be different).  I am a total PS newbie . . . pretty sure that you already knew that.

Thank you very much for all your help, and I will let you know how this comes out.
0
Patrick BogersDatacenter platform engineer LindowsCommented:
Ahh off course...Exchange 2010 cmdlets and scripts require PS 2.0 *sigh*

I understand it is slowly, this was intended so we do not interupt user experience.
This script Will do one pst at a time so it is ok to copy/open one that has finished.

Hear from you later. Glad we Got it working as desired.
0
skbryanAuthor Commented:
Wah!  It appears to be stalled.  It stopped working about the same time that I disconnected from the server, about 3:34pm.  (Obviously, I removed our company and username from the attached screenshots).  

Screenshot1
Screenshot of folder where the export is being dumped (not showing usernames).

Screenshot2
Is there a way to "goose" the command?  Thank you.
0
Patrick BogersDatacenter platform engineer LindowsCommented:
Hi

Too bad but logical since the process in running under your security context.

What do you mean by Goose the command? Have it run while you are offline?
Guess we can let it run as scheduled task which runs one time on demand under the local system security context.

No username shown can be caused by the leading dollarsign in $($i).pst
If you do a dir in elevated dir, does it show usernames?
0
skbryanAuthor Commented:
I'm logged into the server and my command is still up (I never logged out, just disconnected), but it isn't going anywhere.  How would I get it to run whether or not I am connected to the server or not?  I am a domain admin with Mailbox Import Export rights.

By "goose", I meant a command like, "Hey, you still need to run the above command. Please resume where you left off.".   If I reenter and start over, won't it still stall if I am not connected?

The usernames and all that other stuff is there, I just removed it for privacy's sake.  

Thank you for your help.
0
Patrick BogersDatacenter platform engineer LindowsCommented:
Ok Nice.
What does below commands say?
Get-MailboxExportRequest | where {$_.status -eq "Completed"} | Remove-MailboxExportRequest
Get-MailboxExportRequest | where {$_.status -eq "Failed"} | Remove-MailboxExportRequest

Next i wonder what rollup and cu you are running. I know the stuck issue is pre-ru6
0
skbryanAuthor Commented:
Running Exchange 2010 SP3 Rollup 7, Version: 14.03.0210.002

Get-MailboxExportRequest | where {$_.status -eq "Completed"} | Remove-MailboxExportRequest
Get-MailboxExportRequest | where {$_.status -eq "Failed"} | Remove-MailboxExportRequest

Ran the above requests and they behaved as expected.  I confirmed the requested and the commands executed successfully.  

Thanks.
0
Patrick BogersDatacenter platform engineer LindowsCommented:
Are the queues running again?
0
skbryanAuthor Commented:
No, nothing is queued.  Everything showed as completed (but the exported mailboxes did not really export, most of them show 265 kb) or as Failed.  Most of the items showed as Completed.
0
Patrick BogersDatacenter platform engineer LindowsCommented:
Hmm ok. For the bigger experts, can you verify the export is between thr dates specified?
0
skbryanAuthor Commented:
Ran the command to do the export again.  Yup, dates are good.  Will see how this one goes.  Thank you.
0
Patrick BogersDatacenter platform engineer LindowsCommented:
Nice! Fingers crossed
0
skbryanAuthor Commented:
What is seeming to happen is that the folder structure of each mailbox is exported, but none of the emails that are in the folders.   Sad. . .
0
skbryanAuthor Commented:
From another forum (Spiceworks):

Switch your less than and greater than

foreach ($i in (Get-Mailbox)) { New-MailboxExportRequest -ContentFilter {(Received -lt '02/01/2017') -and (Received -gt '11/21/2016')} -Mailbox $i -Filepath "\\10.10.1.35\EmailBackup\$($i).pst" }

Ran it, and it looks promising so far!
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Patrick BogersDatacenter platform engineer LindowsCommented:
Hi again,

I dont see it, can you explain what is different?

Cheers
0
skbryanAuthor Commented:
Switched the greater than and less than dates in the formula.  

FROM:  {(Received -lt '11/21/2016') -and (Received -gt '02/01/2017')}

TO: {(Received -lt '02/01/2017') -and (Received -gt '11/21/2016')}
0
Patrick BogersDatacenter platform engineer LindowsCommented:
Hahaha Nice slipup! Sorry....
0
skbryanAuthor Commented:
It is working!  Thank you for your help.
0
Patrick BogersDatacenter platform engineer LindowsCommented:
You are welcome!
0
skbryanAuthor Commented:
Fixed final piece to make it work.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Exchange

From novice to tech pro — start learning today.