Link to home
Start Free TrialLog in
Avatar of cembi
cembiFlag for United States of America

asked on

How to export old emails of an Exchange 2010 mailbox into PST

I need to make up space in my Exchange 2010 database by moving data older than 1 year into PST file. With Exchange 2003 this was easy by using ExMerge which is not available anymore. Instead there are commands in PowerShell which export whole mailboxes but I haven't been able to find how to export just part of a mailbox which pertains to a certain time period.
Is this possible?
Thank you.
Avatar of Will Szymkowski
Will Szymkowski
Flag of Canada image

Yes this is possible. Use the following cmdlet below...

First you need to assign permissions to a group or user to export mailboxes
New-ManagementRoleAssignment -Role "Mailbox Import Export" -User Administrator

Open in new window


The below command will do this for 1 user. If you need to do this from multiple users i can modify the script as needed.
$Path = "\\yourserver\sharename\name.pst"
$date = get-date
New-MailboxExportRequest -Mailbox User1 -ContentFilter {Received -gt $date.AddDays(-365)} -FilePath $Path

Open in new window


You can also see the HowTo below I have created on my site.
http://www.wsit.ca/how-tos/exchange-server-2/export-mailbox-using-exchange-management-shell-200720102013/

Will.
You can also use Outlook to do the job. Just create an archive and move the messages into it.
Avatar of cembi

ASKER

I will need to do this for about 100 users. I thought about using Outlook but it would a long time to do it. Would need to Export all emails before Jan 1, 2014.
Thank you.
If you have 100 users just add all of the aliases to a text file (one alias on each line). Then use the following script.

$date = get-date
$UserList = get-content "c:\filename.txt"
ForEach ($Alias in $UserList) {
New-MailboxExportRequest -Mailbox $Alias -ContentFilter {Received -gt $date.AddDays(-365)} -FilePath \\servername\share\$Alias.pst
}

Open in new window


Just be aware you still need to run the first command i posted as you need to assign your account or a group with the export permissions.

Will.
If you have additional space on the server for the PST files, you could create a new databasefile for Exchange there, and move a couple of users into it. Users won't notice it, and you have no risk making important old messages invisible.
Avatar of cembi

ASKER

Thanks Will. What if I want to do this in batches of 5 users at a time? What would the command look like? Also, how do I enter date for "before Jan 1, 2014"?
Yes you can do this in batches of 5. Just add 5 names to the text file then run it. For the date range just change the $DATE = "01/01/2014"

Replace the value in the script with the one above.

Will.
Avatar of cembi

ASKER

Hey Will,
When I enter the 3rd and final command I get the error message "The term New-MailboxExportRequest is not recognized as the name of a cmdlet............................"
Any idea why? I am running this through powershell.
Avatar of cembi

ASKER

Anyone has an answer to my last question?
Does you account have the proper permissions "Mailbox Import export"? Also you need to run this in the Exchange Management Shell as well. Those are the 2 reason why you would not see the cmdlet. Snapin is not in the powershell session or you do not have permissions.

Will.
Avatar of cembi

ASKER

The error I receive now is "The provided content filter value is invalid. Content filter is invalid. "" is not a valid operator."
Any idea?
Avatar of cembi

ASKER

Can somebody help? Thanks.
I will test this a little later, tied up at the moment.

Will.
Avatar of cembi

ASKER

Thanks
I have tested this and it works. use the below script.
$UserList = get-content "c:\filename.txt"
ForEach ($Alias in $UserList) {
New-MailboxExportRequest -Mailbox $Alias -ContentFilter {Received -lt "01/01/2014"} -FilePath \\servername\share\$Alias.pst
}

Open in new window


That should do it.

Will.
Avatar of cembi

ASKER

Hey Will. I followed your steps but nothing is happening. After running the 3rd command I only see a cursor, no progress or any other indicator that could show that it is working. The destination folder doesn't show any sign of PST files being saved.
I never thought this could be so complicated.
You need to copy the entire script, save it to notepad, and then save it as a .ps1 file extension. You then open your Exchange Management Shell, navigate to the location where you saved the script. Then type .\filename.ps1

This will initiate the script and the process will start.

Will.
Avatar of cembi

ASKER

User generated image
Based on that error message you are getting you should use the full path in the first line.

$UserList = get-content "c:\Export.txt"

Or whatever your path is. You have only entered "Export.txt"

Will.
Avatar of cembi

ASKER

User generated image
Avatar of cembi

ASKER

Thoughts?
You need to run it like .\Exportation.ps1

Will.
Avatar of cembi

ASKER

User generated image
Avatar of cembi

ASKER

???
ASKER CERTIFIED SOLUTION
Avatar of Will Szymkowski
Will Szymkowski
Flag of Canada 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