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.
cembiIT Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
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.

Will SzymkowskiSenior Solution ArchitectCommented:
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.
ebrinkCommented:
You can also use Outlook to do the job. Just create an archive and move the messages into it.
cembiIT Author Commented:
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.
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Will SzymkowskiSenior Solution ArchitectCommented:
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.
ebrinkCommented:
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.
cembiIT Author Commented:
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"?
Will SzymkowskiSenior Solution ArchitectCommented:
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.
cembiIT Author Commented:
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.
cembiIT Author Commented:
Anyone has an answer to my last question?
Will SzymkowskiSenior Solution ArchitectCommented:
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.
cembiIT Author Commented:
The error I receive now is "The provided content filter value is invalid. Content filter is invalid. "" is not a valid operator."
Any idea?
cembiIT Author Commented:
Can somebody help? Thanks.
Will SzymkowskiSenior Solution ArchitectCommented:
I will test this a little later, tied up at the moment.

Will.
cembiIT Author Commented:
Thanks
Will SzymkowskiSenior Solution ArchitectCommented:
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.
cembiIT Author Commented:
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.
Will SzymkowskiSenior Solution ArchitectCommented:
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.
cembiIT Author Commented:
Error message
Will SzymkowskiSenior Solution ArchitectCommented:
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.
cembiIT Author Commented:
New Error
cembiIT Author Commented:
Thoughts?
Will SzymkowskiSenior Solution ArchitectCommented:
You need to run it like .\Exportation.ps1

Will.
cembiIT Author Commented:
New-Picture--37-.bmp
cembiIT Author Commented:
???
Will SzymkowskiSenior Solution ArchitectCommented:
I see the reason now. You have spaces in your -FilePath. That means you will need to put quotes around it.

It should be "\\192.168.16.25\PST Export\$Alias.pst"

Once you have quotes around your -FilePath it should work with no issues.

Will.

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
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.