Using the Exchange 2010 SP1 Mailbox Export features for Mass Exports to PST files
In Exchange 2007 SP1 thru to Exchange 2010 RTM, the Export-Mailbox command was the replacement for the once-familiar ExMerge utility when it came to exporting mailboxes to PST files.
The main problem with Export-Mailbox for most Exchange administrators is the requirement for Outlook – either on a 32-bit machine with Management Tools for Exchange 2007, or on a 64-bit machine for Exchange 2010. All in all, it wasn’t ideal and certainly didn’t facilitate scripted mailbox exports.
Thankfully, with Exchange 2010 SP1, Export-Mailbox is going the way of the dodo and new cmdlets for Mailbox imports and exports are available. Just like the New-MoveRequest cmdlet, the new import/export command use the Mailbox Replication Service to perform the move via one of the Client Access Servers giving performance benefits, such as ensuring the PST transfer doesn’t have to go via the machine with the Exchange Management Tools/Outlook installed, as was the case previously.
The main aim of this post is to give you an overview of how to use the new mailbox export cmdlets, and then show you how to put them to practical use, both at the command line and with a scheduled task for brick-level backups.
Getting it set up
The basic requirements for using the new feature are pretty straightforward. You need to use an account that’s a member of the organisational management groups, and have the “Mailbox Import Export” role assignment assigned to you or a role group you’re a member of. As the export is done at a CAS server (and if you’ve multiple CAS servers you can’t specify which one in each site will be used) you can’t specify a local drive letter and path – you must specify a UNC path to a network share that the “Exchange Trusted Subsystem” group has read/write access to.
Step One
Create a share on a server, and grant Exchange Trusted Subsystem read/write permission. In this example I’m using a share called Exports on a test server called Azua in my lab environment:
Step Two
Next, you’ll need to grant a user, or group, the Mailbox Import Export role assignment. You can do this using the Exchange Management shell with a single command. In this example, I’m granting my lab domain’s Administrator user the role assignment:
GeSHi Error: GeSHi could not find the language powershell (using path /home/content/03/9366303/html/wp-content/plugins/codecolorer/lib/geshi/) (code 2)
After you’ve done this, close and re-open the Exchange Management shell, and you’re ready to go!
Exporting a Mailbox
At it’s simplest, use the New-MailboxExportRequest command with the –Mailbox parameter, to specify the mailbox to export along with the –FilePath parameter, to specify the PST file to create and export data to, e.g:
GeSHi Error: GeSHi could not find the language powershell (using path /home/content/03/9366303/html/wp-content/plugins/codecolorer/lib/geshi/) (code 2)
In addition, there are some other useful options – such as –BatchName, which allows grouping of requests together, and –ContentFilter, which allows only certain content to be exported to the PST – useful for discovery purposes. As usual, use the Get-Help New-MailboxExportRequest –detailed command to review the full plethora of options.
After submission of your requests, you can check progress, including the percentage complete, with the two Get-MailboxExportRequest and the Get-MailboxExportRequestStatistics commands. Pipe the former into the latter to get a listing:
GeSHi Error: GeSHi could not find the language powershell (using path /home/content/03/9366303/html/wp-content/plugins/codecolorer/lib/geshi/) (code 2)
After the requests complete, you can remove the requests in a similar fashion, using the Remove-MailboxExportRequest command:
GeSHi Error: GeSHi could not find the language powershell (using path /home/content/03/9366303/html/wp-content/plugins/codecolorer/lib/geshi/) (code 2)
Performing mass exports
One benefit of Powershell is it’s very easy to put together commands enabling mass-exports of PST data with only a few commands. If you really wanted to, you could even use a Powershell script as a secondary brick-level backup!
The Basics
So to check out how to do this, let’s look at it’s simplest – backing up all the mailboxes (assuming it’s a full Exchange 2010 environment) to a single share:
GeSHi Error: GeSHi could not find the language powershell (using path /home/content/03/9366303/html/wp-content/plugins/codecolorer/lib/geshi/) (code 2)
In the above example, we’re simply performing a for-each loop through each mailbox and creating a new Mailbox Export Request, using the alias to build the name for the PST.
But – what if we’re in a mixed environment, and only want to target the Exchange 2010 mailboxes?
GeSHi Error: GeSHi could not find the language powershell (using path /home/content/03/9366303/html/wp-content/plugins/codecolorer/lib/geshi/) (code 2)
In this example above, now, we’ve added a clause to only select the mailboxes where the Exchange Major Build is 14 – Exchange 2010. Simple!
Moving on from such wide-targeting, you may want to target just a pre-defined list, using a CSV file. To do this, simply create a CSV file with the column “Alias”, and list the Mailbox alias fields you wish to export. Then, using the Import-CSV command we can use this CSV file to create the requests:
GeSHi Error: GeSHi could not find the language powershell (using path /home/content/03/9366303/html/wp-content/plugins/codecolorer/lib/geshi/) (code 2)
Performing Mass Exports as a scheduled task
Now you’ve seen the basics of how easy it is to perform mass mailbox exports using the New-MailboxExportRequest command, I’ll finish off with a final example showing how to use this mass export feature as part of a scheduled task.
This script is aimed at backing up all the mailboxes on a single database, or a single server. After creating the requests, it waits for the requests to complete then, if you’ve specified a report directory, it will write reports showing completed and incomplete (i.e. failed!) requests. Finally it removes the requests it created.
To use the script, you need to alter the config section and specify either a server or a database, a share to export to, a share to write a report to after the process has completed and you can choose whether to remove each mailbox’s associated PST file or leave as-is at each export – merging the contents.
You’ll see the content of the script below and at the bottom of the post I’ve zipped it up along with a bootstrap CMD file you could use when setting up a schedule task. As always – use at your own risk and test out in your lab environment first. Happy Exporting!
GeSHi Error: GeSHi could not find the language powershell (using path /home/content/03/9366303/html/wp-content/plugins/codecolorer/lib/geshi/) (code 2)
Command file contents:
GeSHi Error: GeSHi could not find the language powershell (using path /home/content/03/9366303/html/wp-content/plugins/codecolorer/lib/geshi/) (code 2)
Related posts:



September 21st, 2011 - 07:26
Hi Steve,
Can you please advise if it’s possible to convert Exchange 2010 mails (please note it’s not Exchange 2010 SP1 here) to PST.
Thanking you in advance.
Rgds,
Sylaish.
September 14th, 2011 - 23:46
Just wanted to say thanks for this script. its well thought out and well written. Very useful. Cheers.
September 8th, 2011 - 17:43
Now, only if we could clear those mailboxes out or disable them, like the old ExMerge… Any ideas?
September 9th, 2011 - 23:00
Hi Jon,
You should be able to use Search-Mailbox with the -DeleteContent switch to do this
Steve
September 7th, 2011 - 18:16
When I run the script it appears to execute without error but I am not getting any pst files as a result. There are no error messages in event viewer. There was no error message in powershell [after I modified the cmd file to point to the location of the ps1 file]. Does it take a really long time [more than an hour] to produce even a single pst? Is there a way to monitor the progress?
September 7th, 2011 - 22:09
Update: I am able to export a single mailbox to a pst file but still no joy with the script. I did modify the ps1 file variables for $Server ; $ExportShare and $ReportShare as required. I also ran the cmdlet [New-ManagementRoleAssignment –Role “Mailbox Import Export” –User AD\Administrator] adjusted for my domain. I don’t see anything else needed in order for this to work. Also, I reread the post above and found the cmdlet for checking the status [Get-MailboxExportRequest | Get-MailboxExportRequestStatistics]. This says nothing is happening after running the script. I hope you can help me resolve this as this would be really cool to get working
. Thanks much in advance!!
September 7th, 2011 - 22:11
Hiya,
Do you not even see the exports scheduled?
Steve
September 7th, 2011 - 22:21
I don’t. The script appears to run and complete without error. But nothing actually happens. There are no events posted in the event viewer. There are no logs written in the file share. Can you think of any other place to look for clues? Thanks again.
September 7th, 2011 - 22:23
Off the top of my head, I can’t – it’s been a while since I wrote this script. I’ll need to run it and look for any bugs that might cause this to happen.
September 7th, 2011 - 03:57
Hi, I have loved your great website. I have bookmarked your site so, will check in now and then. Thank you!
August 22nd, 2011 - 14:21
Hi,
Me again, is there also maybe a way to prevent the export of disabled mailboxes?
Thanks
Raymond
August 30th, 2011 - 23:25
Question: I am trying to export multiple pre-listed mailboxes in a export.csv file, located on various DBs. My question is how do I specify the location of the export.csv in this command?
foreach ($i in (Import-csv .\exports.csv)) {New-MailboxExportRequest -mailbox $i.alias -FilePath “\\brockhaus\ex2010exports$\$($i.alias).pst”}
August 22nd, 2011 - 13:23
Hi,
Forgive my n00bishness, but how would I be able to mail the report instead of saving it to a UNC path or local path?
Thanks in advance.
Raymond
August 23rd, 2011 - 10:28
Hiya
This should be possible if you add a line to the script similar to this:
GeSHi Error: GeSHi could not find the language text (using path /home/content/03/9366303/html/wp-content/plugins/codecolorer/lib/geshi/) (code 2)
Steve
July 26th, 2011 - 11:23
Thank you so much for your wonderful advices. I was able to successfully export .pst files with individual command. Will look further with the batch to do for the whole exchange mailboxes. it truly save me a lot of time if otherwise have to go to each station and do the export. Thank you!
July 25th, 2011 - 22:38
An answer to Tucker Watts’ question.
Take a look at this guide:
http://exchangeserverpro.com/exchange-2010-mailbox-database-backup-restore-windows-server-backup
July 25th, 2011 - 22:17
Hello everyone!
Did anyone of you got it working under Task Scheduler ? It just doesn’t do anything even though the tasks seems to be completed successfully but the error code is 1 which is not good.
July 25th, 2011 - 23:05
Hi Eugune,
It should work under task scheduler, though it needs to be started with the right level of credentials. To be honest, it’s been a little while since I’ve revisited this script so a re-write may be in order.
The code 1 is to do with it running from the batch script.
Steve
July 25th, 2011 - 21:42
How would you mass export all mailboxes in a single database?
July 25th, 2011 - 23:19
Hiya,
You should be able to set the $Database = “” variable in the script instead of $Server to do this.
Steve
July 19th, 2011 - 21:39
Hi. Great script. Thanks. One question…if you export to a pre-existing PST, does it only write the changes? It seems like it might given the -ConflictResolutionOption switch in the command. Thanks again.
July 19th, 2011 - 21:42
Hi Gabriel,
The intention is that it would write a fresh PST each time, as the ConfictResolutionOption won’t deal with deleted items from the PST.
Steve
July 4th, 2011 - 12:00
Sorry guys,
When I copied the code, I missed a line and the code didnt work. The following is a fully working and tested.
# Exchange 2010 SP1 Mailbox Export Script
# Steve Goodman. Use at your own risk!
#Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin
#Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010
###############
# Settings #
###############
# Pick ONE of the two below. If you choose both, it will use $Server.
$Server = “”
$Database = “”
# Share to export mailboxes to. Needs R/W by Exchange Trusted Subsystem
# Must be a UNC path as this is run by the CAS MRS service.
$ExportShare = “”
# After each run a report of the exports can be dropped into the directory specified below. (The user that runs this script needs access to this share)
# Must be a local full path of a local directory.
$ReportShare = “c:\pst.log”
# Shall we remove the PST file, if it exists beforehand? (The user that runs this script needs access to the $ExportShare share)
# Valid values: $true or $false
$RemovePSTBeforeExport = $true
# How many simultaneous exports can accoure
$SimultaneousExport = 6
###############
# Code #
###############
Get-MailboxExportRequest | Remove-MailboxExportRequest -confirm:$false
$date=Get-Date
$(“Backup start time: “)+$(get-date)|out-file -encoding ascii -filepath $ReportShare -Append
# Queue all mailbox export requests
foreach ($Mailbox in (get-mailbox -filter{servername -eq $server}))
{
if ($RemovePSTBeforeExport -eq $true -and (Get-Item “$($ExportShare)\$($Mailbox.Alias).pst” -ErrorAction SilentlyContinue))
{
Remove-Item “$($ExportShare)\$($Mailbox.Alias).pst” -Confirm:$false
}
New-MailboxExportRequest -Mailbox $Mailbox -ExcludeFolders “#DeletedItems#” -FilePath “$($ExportShare)\$($Mailbox.Alias).pst”
# Limiting simultaneous export
while ((Get-MailboxExportRequest -status inprogress|Measure-Object -Character -Line).lines -ge $SimultaneousExport){start-sleep 30}
}
start-sleep 30
while ((Get-MailboxExportRequest -status inprogress|Measure-Object -Character -Line).lines -ge 1){start-sleep 60}
# Write reports if required
Get-MailboxExportRequest | Where {$_.Status -ne “Completed”}| Get-MailboxExportRequestStatistics|out-file -encoding ascii -filepath $ReportShare -Append
$(“Backup end time: “)+$(get-date)|out-file -encoding ascii -filepath $ReportShare -Append
$(“”)|out-file -encoding ascii -filepath $ReportShare -Append
#Clean Mailbox EExport Request
Get-MailboxExportRequest | Remove-MailboxExportRequest -confirm:$false
July 4th, 2011 - 23:47
Thanks Kobbygl
Steve
July 4th, 2011 - 11:36
Hi Guys,
When I started the mass export using the script, I start getting after a wile, a lot of:
+ CategoryInfo : NotSpecified: (0:Int32) [New-MailboxImportRequest], RemotePermanentException
I managed to narrow it down, to the amount of exports, my exchange server can do at the same time which is 20. I have tried to find if I can change the limit in some of the exchange config files, but couldn’t find anything. At the end I have made some changes to the script above, adding a limit to the amount of simultaneous export. I hope it will be useful for you guys as well.
The script can be run from a Task scheduler as well and not just from the Exchange powershell. It’s limited he Export just to 7. I found that to many export will take much longer for all the mailboxes the just few at each time. I have also excluded the DeletedItems export from each mail box (it is down to you if you wont it or not – it can be just removed from the code in line 47.
Now to the code:
# Exchange 2010 SP1 Mailbox Export Script
# Steve Goodman. Use at your own risk!
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010
###############
# Settings #
###############
# Pick ONE of the two below. If you choose both, it will use $Server.
$Server = “mrpostman2″
$Database = “”
# Share to export mailboxes to. Needs R/W by Exchange Trusted Subsystem
# Must be a UNC path as this is run by the CAS MRS service.
$ExportShare = “\\totalrecall\pst2010″
# After each run a report of the exports can be dropped into the directory specified below. (The user that runs this script needs access to this share)
# Must be a UNC path or the full path of a local directory.
$ReportShare = “c:\pst.log”
# Shall we remove the PST file, if it exists beforehand? (The user that runs this script needs access to the $ExportShare share)
# Valid values: $true or $false
$RemovePSTBeforeExport = $true
# How many simultaneous exports can accoure
$SimultaneousExport = 6
###############
# Code #
###############
Get-MailboxExportRequest | Remove-MailboxExportRequest -confirm:$false
$date=Get-Date
$(“Backup start time: “)+$(get-date)|out-file -encoding ascii -filepath $ReportShare -Append
# Queue all mailbox export requests
foreach ($Mailbox in (get-mailbox -filter{servername -eq $server}))
if ($RemovePSTBeforeExport -eq $true -and (Get-Item “$($ExportShare)\$($Mailbox.Alias).PST” -ErrorAction SilentlyContinue))
{
Remove-Item “$($ExportShare)\$($Mailbox.Alias).PST” -Confirm:$false
}
New-MailboxExportRequest -Mailbox $Mailbox -ExcludeFolders “#DeletedItems#” -FilePath “$($ExportShare)\$($Mailbox.Alias).PST”
# Limiting simultaneous export
while ((Get-MailboxExportRequest -status inprogress|Measure-Object -Character -Line).lines -ge $SimultaneousExport){start-sleep 30}
}
start-sleep 30
while ((Get-MailboxExportRequest -status inprogress|Measure-Object -Character -Line).lines -ge 1){start-sleep 60}
# Write reports if required
Get-MailboxExportRequest | Where {$_.Status -ne “Completed”}| Get-MailboxExportRequestStatistics|out-file -encoding ascii -filepath $ReportShare -Append
$(“Backup end time: “)+$(get-date)|out-file -encoding ascii -filepath $ReportShare -Append
$(“”)|out-file -encoding ascii -filepath $ReportShare -Append
#Clean Mailbox EExport Request
Get-MailboxExportRequest | Remove-MailboxExportRequest -confirm:$false
June 24th, 2011 - 05:43
Steve,
I want to thank you for this article. I was able to import a pst to a mailbox on my Exchange 2010 test environment. However I get the following message on my production environment:
Couldn’t connect to the target mailbox.
+ CategoryInfo : NotSpecified: (0:Int32) [New-MailboxImportRequest], RemoteTransientException
+ FullyQualifiedErrorId:*******,Microsoft.Exchange.Management.RecipientTasks.NewMailboxImportRequest
Any advise?
Thanks
Ed
June 24th, 2011 - 10:21
These have been reported a lot online but I’ve still yet to see the definitive answer. I’ve not come across it since a particular bug that caused this was fixed (before SP1 release).
I see that UR4 has some more fixes for New-MailboxImportRequest but I don’t know if they will fix the specific problem. It is worth a try, though.
June 20th, 2011 - 21:59
I created the share and added the permissions but I get this error every time.
The server or share name specified in the path may be invalid, or the file could be locked.
+ CategoryInfo : NotSpecified: (0:Int32) [New-MailboxImportRequest], RemotePermanentException
+ FullyQualifiedErrorId : C7732F9,Microsoft.Exchange.Management.RecipientTasks.NewMailboxImportRequest
Share & NTFS permissions have Exchange Trusted Subsystem, Role assignmnet had been done and I an running Exchnage PS as Administrator.
May 9th, 2011 - 12:29
One more thing!
In a multi tennanted scenario, with multiple domains, using the alias in the export cmd is causing multple matching entries and some of the exports fail, I’ve changed:
New-MailboxExportRequest -BatchName $BatchName -Mailbox $Mailbox.Alias -FilePath…
to
New-MailboxExportRequest -BatchName $BatchName -Mailbox $Mailbox.DisplayName -FilePath…
Not sure if it’s the best way of sorting this, but it’s working for me!
May 13th, 2011 - 17:39
Hiya,
Just seen your comments, glad you’ve sorted out the problems you had. Out of interest when you say multi-tenant, is this in a /hosting mode install?
Steve
May 9th, 2011 - 12:10
Ammended as below works for me!
# Wait for mailbox export requests to complete
while ((Get-MailboxExportRequest -BatchName $BatchName -MultiTenant | Where {$_.Status -eq “Queued” -or $_.Status -eq “InProgress”}))
May 9th, 2011 - 11:41
I’m running this wicked script in a lab envronment on a multi tennant install of 2k10 sp1 and the export works perfectly, but fails at “# Wait for mailbox export requests to complete” because the cmd “Get-MailboxExportRequest -BatchName $BatchName” returns nothing and the script finishes early so the clearing up of the export requests doesnt happen, neither does the logging.
Get-MailboxExportRequest -Organization orgname -BatchName $BatchName works, but only for the specified org…
May 3rd, 2011 - 11:35
Hi boys,
is here any working solutin for:
New-MailboxExportRequest –Mailbox “organization\user” –Filepath “\\CASHUB01\PST\user.pst”
Couldn’t connect to the source mailbox.
+ CategoryInfo : NotSpecified: (0:Int32) [New-MailboxExportRequest], RemoteTransientException
+ FullyQualifiedErrorId : 49348511,Microsoft.Exchange.Management.RecipientTasks.NewMailboxExportRequest
Thanks Biba
May 3rd, 2011 - 22:39
Hi Biba,
Does it occur on every mailbox you try, regardless of the database? Are there any errors logged in the event log?
Steve
May 4th, 2011 - 07:32
Hi Steve,
i try administrator and two of users mailboxes … same result (Only one MBX DB)
MSExchange management LOG shows:
Cmdlet failed. Cmdlet New-MailboxExportRequest, parameters {Mailbox=biba.cz\user, FilePath=\\CASHUB\PST\user.pst}.
MAPI is enabled, Get-CASmailbox shows everything correct
Thanks B.
April 29th, 2011 - 18:04
Very good script! Thank you for all your efforts, Steve!
I altered by adding an unhide command at the top and bottom. We use the script as part of our account decommissioning process so all the mailboxes that need a PST are in 1 DB. Below is the command I added at the beginning of the script. I just reverse it at the end.
get-mailbox -database “Cancelled PST Processing” | set-mailbox -hiddenfromaddresslistsenabled $false
I’m hoping the change will reduce the transient errors. I’m running E2K10 SP1 RU3 so it’s as up-to-date as possible.
April 13th, 2011 - 17:46
GREAT Article!!!
After researching over 6 hours on how to Export a mailbox to a PST file SUCCESSFULLY {which was rediculious because E2k3 was simple and straight forward with ExMerge that everyone was used to} I finally found this post… THANK GOD!
I honestly think the requirements to do a regular simple Admin task like this is plain %^$*. Exchange features has gone forward, while its seems trying to administer it has gone backwards at light speed.
Thank You, Thank You, Thank You for this post and work. Much Appreciated.
April 26th, 2011 - 19:17
Cheers glad it was useful
Steve
April 11th, 2011 - 17:06
Hi stevie….this script work great….I would like to add a script to compress each pst file using the compression of windows. Can you help me?
April 7th, 2011 - 11:25
Just wanted to let people know that this will fail with an absurd error if you don’t have the MAPI, POP3 and IMAP4 features enabled.
I know is evident, but if you are doing the leavers of your company as you did with Exchange 2007 you might found this issue and go crazy.
Thanks for a really good guide !!
April 5th, 2011 - 13:15
every second time i run the CMDLET
New-MailboxExportRequest -Mailbox “Discovery Search Mailbox” -Name username -FilePath “\\servername\share\pstname.pst” -SourceRootFolder “username”
i get this error
Unable to open PST file “\\servername\share\pstname.pst. Error details: Data read at file offset 0 is 0 bytes. It should have been 576 bytes
Please help ??
April 5th, 2011 - 13:00
Hi
I have i problem with Import export mailboxes
I run run this
New-MailboxExportRequest -Mailbox “Discovery Search Mailbox” -Name username -FilePath “\\servername\share\pstname.pst” -SourceRootFolder “username”
Error
The server or share name specified in the path may be invalid, or the file could be locked.
nothing wrong with share or permission
Please help ??
March 22nd, 2011 - 15:55
Great Script! Can’t wait to use this!
Back in the day I had a friend create a java script that would use Exmerge to export the last 30 days of a users mailbox to a pst into a folder named by the year and month. Then when the month changed so did the destination folder. So you would see folders like this…(2010-11, 2010-12, 2011-01). This would keep going as long as you had the space. I would eventually burn the PST’s to DVD. You can’t imagine how many users delete stuff from a year or more ago and ask to recover it. So I came up with this solution.
My question is, can this be done from a power shell script?
March 11th, 2011 - 21:15
I’ve been using your script for a while now during our initial setup. I’m at the point where I’m migrating users from POP3 to Exchnage Connector so email will start sitting on the server full time and I now need to automate your script. I’m having some trouble getting it run on 2008 R2 as a scheduled task. Same as another user on your page here only the provided solution does not work.
I verified that I can run the CMD file from the command line:
c:\>”C:\Users\administrator.MAISTO\Desktop\Exchange Backup Scripts\PST Incremental Backup\PST_Incremental.cmd”
The PS1 file is in the same folder as the CMD file so as you can see I added the full path to the PS1 file.
That works fine. The export runs and finishes. However, when the task starts it enters a RUNNING state and simply stays there indefinitely. I see it starts a cmd.exe process and it just sits there and does nothing. I’m running the task as domain admin and I made sure that same account has FULL permissions on all files/folders used as well as the target.
As a test I created and ran a simple CMD file consisting of dir > c:\test.txt and that works fine.
Hopefully you or someone else has a trick up their sleeve. I’m out of ideas after a couple days of this.
March 11th, 2011 - 23:03
Update, if I select Run Only When User Is Logged On then it works. If I select Run Whether User Is Logged On Or Not then it simply runs forever and does nothing.
Hum…..
May 23rd, 2011 - 08:17
Hi Jemlay,
Did you sort this out? I’m in the exact same situation and don’t really know what to do from here.
Thanks
March 11th, 2011 - 04:19
Great Post – I get this error:
Couldn’t connect to the source mailbox.
+ CategoryInfo : NotSpecified: (0:Int32) [New-MailboxExportRequest], RemotePermanentException
+ FullyQualifiedErrorId : 6847F860,Microsoft.Exchange.Management.RecipientTasks.NewMailboxExportRequest
Do you know anything about this?
March 10th, 2011 - 17:34
Hi Steve,
Thanks for this its really useful.
Can you tell me how I can have the PST name to be the email address instead of the alias.
Thanks,
Geoff.
February 25th, 2011 - 17:23
I used your string to do an export on a group of mailboxes referenced in a csv file [exports.csv] and the resulting pst files are named oddly. Do I need to edit the command?
foreach ($i in (Import-Csv .\exports.csv)) { New-MailboxExportRequest -Mailbox $i.Alias -FilePath “\\bro
ckhaus\ex2010Exports$\$($i.Alias).pst” }
resulting file name: @{alias=tdane}.alias).pst
This is Exchange 201 SP1
Daria
February 25th, 2011 - 17:26
Do you have an example line and header from the CSV file?
Steve
February 25th, 2011 - 18:43
It is one column, the word alias in A:1, then the username tdane in A:2
alias
tdane
etc
March 8th, 2011 - 22:00
I was able to fix this by removing the spaces just inside of the brackets { }
Good:
foreach ($i in (Import-csv .\exports.csv)) {New-MailboxExportRequest -mailbox $i.alias -FilePath “\\brockhaus\ex2010exports$\$($i.alias).pst”}
Not Good:
foreach ($i in (Import-Csv .\exports.csv)) { New-MailboxExportRequest -Mailbox $i.Alias -FilePath “\\brockhaus\ex2010Exports$\$($i.Alias).pst” }
February 18th, 2011 - 11:14
Hello,
I’ve used your script and it works perfectly when I run it manually but when I try to task schedule it, it does nothing…
In task scheduler, I got de result code 0×41301 (task running) for 10 minutes and then 0×1 (bad…)
I’ve scheduled de MassExport.cmd
Can someone help me ?
Donovan
(I speak french, sorry if my english is bad
February 19th, 2011 - 22:12
Hi Donovan,
Does the MassExport.cmd script run at the command line OK? What user are you scheduling the job as – is it the same as the one you can successfully run it as interactively?
Steve
February 21st, 2011 - 11:04
Hi Steve,
Thanks for reply.
I didn’t try to run at the command line, but the user scheduled is the domain administrator. (the same I use when I run MassExport.cmd manually)
I will try to run MassExport at the command line this week.
Donovan
February 24th, 2011 - 11:54
Hi Steve,
I tried to run MassExport.cmd from de CMD and everything is working perfectly…
Have you got any other ideas ?
Donovan
February 27th, 2011 - 12:30
Hi Donovan,
I had exactly the same problem the first time, I tried to schedule this great script.
My solution was to add the path to the script ps1 file in the MassExport.cmd file. For example:
C:\Scripts\Mailbox_Export\MassExportMailbox.ps1
Otherwise you could in the scheduled task actions pane – Edit the job – add the parameter “start in” with the path to your “MassExportMailbox.ps1″ file. That should work to.
Hope this does the trick for you.
Jeppe
March 9th, 2011 - 11:29
Hello !
add the path in the MassExport.cmd did work fine
Thank you very much !
Donovan
January 17th, 2011 - 17:10
Steve – thanks for all the hard work. I am having a problem running this script because the users I want to run it against are in a child domain so it doesn’t appear to be “seeing” them. Is there a parameter I need to use?
December 11th, 2010 - 10:06
Before exporting, make sure you have:
- Access rights to the mailbox and write rights to the share you are writing the pst files
- The mailbox is enabled (mapi)
- The mailbox is visible in the address list
If the mailbox is not visible or enabled, you will get the “Couldn’t connect to the source mailbox” error.
Erik
December 11th, 2010 - 10:09
Hi Erik,
The connection to mailbox is performed using the Exchange trusted subsystem. The user performing the export doesn’t need access rights to the mailbox, and it’s the Exchange Trusted subsystem that requires access to the share.
Steve
February 23rd, 2011 - 16:34
“- The mailbox is enabled (mapi)” did solve my “Couldn’t connect to the source mailbox” error on a multi-role box.
December 6th, 2010 - 18:16
Steve,
First off, thanks for the script, you saved me a boatload of time.
I’d like to archive into a pst file for messages older than 6 months, and attach the year of the messages onto the archive file. For example, running the archive on January 1, 2011, archives all messages prior to 6/30/2010 into the file “Username2010.PST”. I guess I need to know what the syntax is for deducting 6 months from date.Year.
Thanks for all the help
December 6th, 2010 - 21:15
setting $ReceivedDate=(Get-Date).AddMonths(-6)
and then…
New-MailboxExportRequest -BatchName $BatchName -Mailbox $Mailbox.Alias -FilePath “$($ExportShare)\$($Mailbox.Alias)\$($Mailbox.Alias)$($date.AddMonths(-6).Year).PST” -ContentFilter {Received -lt $ReceivedDate} -ExcludeFolders “#JunkEmail#”, “#Contacts#”, “#Notes#”
did the trick!
Now onto figuring out how to replace the -DeleteContent
December 6th, 2010 - 21:45
You worked it out quickly, only just seen your comments.
I am guessing you need the right AQS for Search-Mailbox to do it. I’ll see what I can work out
December 7th, 2010 - 16:20
Had a quick look today, it seems this works, if done after the export:
Search-Mailbox $Mailbox.Alias -SearchQuery “Received:< $($RecievedDate.ToString())” -DeleteContent
As always worth testing for yourself
Hope this helps
Steve
December 3rd, 2010 - 19:10
Thanks a lot for sharing, great script too
December 4th, 2010 - 22:14
Hi NiTRo,
Glad you like it.
Steve
December 2nd, 2010 - 01:50
Awesome writeup! It helped me a lot. I jumped on board with 2010 SP1 so the amount of Beta versus RC versus SP1 info on the web is craziness!
Exchange 2010 SP1
I’m able to do everything ‘locally’. In other words while using the UNC \\(exchangeserver)\c$\pst.
However, when I start to branch out I run into some issues.
1. If I try to export to \\(remote Server)\C$\PST\user.pst – I get a denied error even though I specify ‘Exchange Trusted Subsystem’. I can only get it to work if I create a SHARE and give the share ‘Exchange Trusted Subsystem’. Both scenarios are the same exact folder.
2. I need to dump these to my Linux box and I get a completely different error when I try to export to it:
‘The server or share name specified in the path may be invalid, or the file could be locked.’
Even though the Exchange machine has full access to this path.
Any ideas? Thanks Again!
December 4th, 2010 - 22:14
Hi Jemlay,
Glad to help
With 1) – if you’re using C$ then you will need to have added Exchange Trusted Subsystem to the Local Admins on the remote server. I’d go further and say that the second way you tried is best practise.
For 2) you will need to have Samba working in a way that is very compatible with Microsoft technologies. It’s not connecting as a user per-se, it’s connecting as the computer account on the Exchange Server. If you let me know how you’ve configured Samba I may be able to help as I’ve worked on some large Samba projects in the past.
Steve
December 9th, 2010 - 01:18
I’m a Linux dummy. In my case, this box is (or was) an Adaptec SnapServer. Storage server. That division was bought out by Overland.
While I have full access to connect to it (which I do via putty) I’ve come to discover some functions are simply not there or not installed.
What I can execute on that server to dig up the info you require?
Thanks for the help!!!
December 11th, 2010 - 10:11
I’d need to see the smb.conf, but if you can’t change the samba config because it’s a black-box type solution it may be worth just using a Windows server.
Steve
December 13th, 2010 - 18:14
I ran ‘less smb.conf’ and got this:
workgroup = MY-DOMAIN
server string = Snap Server
timestamp logs = yes
dos filetimes = yes
dos filemode = yes
inherit acls = yes
name cache timeout = 0
winbind uid = 101-6000000
winbind gid = 101-6000000
guest account = guest
map to guest = Never
unix charset = CP1252
dos charset = CP850
allow trusted domains = yes
security = ADS
disable netbios = no
password server = *
encrypt passwords = Yes
username level = 5
debug level = 0
load printers = no
utmp directory = /var/run
utmp = yes
name resolve order = host lmhosts wins bcast
ldap timeout = 5
restrict anonymous = 2
include = /etc/smb.conf.perm
include = /etc/smb.conf.extra
include = /etc/smb.conf.dm
include = /etc/smb_shares.conf
smb.conf.perm:
panic action = /usr/bin/backtrace %d > /tmp/segv_samba_%d.out 2>&1
# root preexec = /usr/local/samba/bin/log_connect.sh ‘%u’ ‘%m’ ‘%I’ ‘%S’
# root postexec = /usr/local/samba/bin/log_disconnect.sh ‘%u’ ‘%m’ ‘%I’ ‘%S’
username level = 0
realm = MY-DOMAIN.COM
smb_shares.conf:
[Root]
path = /shares/Root
read only = no
comment =
public = yes
follow symlinks = no
printable = no
browseable = no
map acl inherit = yes
create mask = 0777
security mask = 0777
directory mask = 0777
directory security mask = 0777
create mask_ext = 0777
directory mask_ext = 0777
guest ok = No
write list = \
@”AllUsers”
[Backup]
path = /shares/Backup
read only = no
comment =
follow symlinks = no
printable = no
browseable = yes
map acl inherit = yes
create mask = 0777
security mask = 0777
directory mask = 0777
directory security mask = 0777
create mask_ext = 0777
directory mask_ext = 0777
guest ok = No
write list = \
@”AllUsers”
There is no, smb.conf.extra or smb.conf.dm.
In addition these are my options under the Windows setup (SMB):
Member of – Active Directory Domain
Disabled – Enable Guest Account
Enabled – Opportunistic Locking
Enabled – Enable as master browser
Enabled – Allow Root
Disabled – NetBIOS over TCP/IP
Enabled – Trusted Domains
I hope some of this helps. Thanks again for all your time!
December 10th, 2010 - 02:03
On a side note. I exported all my PST files. Then I locked a bunch of the resulting PST files and ran your script again. Obviously it could not write those files (EMS stated as such, no access) so the PST’s where in fact not written out anywhere yet the status still shows as completed. It’s possible that this whole script could run and claim everything is OK when in fact you are not getting your exports.
That’s a little scary
December 11th, 2010 - 10:17
This is a free solution so it’s of course not perfect. Even with enterprise backups it’s important to check that the backups are valid each day rather than just “set it and forget it”.
Additionally it should be combined with a proper backup of the environment in case a of a DR restore. The exports are great to save having to restore a whole DB to a recovery database and then import data.
Steve
November 3rd, 2010 - 14:44
Great post!,
there is an typo in the foreach command:
${$ needs to be $($
November 4th, 2010 - 09:55
Hi Micha,
Thanks, updated and removed the typo
Steve
October 13th, 2010 - 23:16
Hi
Im trying to do a mailbox export (exchange 2010 Sp1) and i am getting an error couldnt find the enterprise organisation container..could you please help
November 4th, 2010 - 09:54
Hiya,
At which part do you get an error? Does get-mailboxdatabase work? If not, what is the output?
October 11th, 2010 - 19:41
I’m having what appears to be a large problem after assigning the “Mailbox Import Export” role to Administrator. I have a stand alone Exchange 2010 server. After entering cmd below:
New-ManagementRoleAssignment –Role “Mailbox Import Export” –User “Administrator”
…I now get error in EMC “You don’t have sufficient permissions to view this data” when logged onto server as Administrator.
October 13th, 2010 - 11:00
Hi Jamie,
There is no reason for these two to be related – though you can import the default management role assignments again..
1) Launch Exchange powershell
2) Run “Add-pssnapin microsoft*”
3) Run “install-CannedRbacRoles”
4) Run “Install-CannedRbacRoleAssignments”
5) Close powershell
Does that help?
Steve
September 20th, 2011 - 21:45
I too had the error:
“The term ‘New-ManagementRoleAssignment’ is not recognized as the name of a cmdlet, function, script … etc…”
This fixed it for me:
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010
September 20th, 2011 - 22:36
Hi Eddie,
I’d recommend trying out the instructions to add the permissions using RBAC, as using Add-PSSnapin may work, but it’s not supported by Microsoft and bypasses the Exchange permissions model.
Steve
September 28th, 2010 - 13:38
Good Article… However i installed SP1, no problems. I can see the change in Version number in the EMC and new features in OWA. However for some bizzae reason none of the new CMDLETS appears. If i ask for a list of CMDLETS, none of the new SP1 CMDLETS appears and trying to execute any of these new ones simply comes back with this CMDLET is not found.
I can see a number of people with this same issue. Anybody have a solution for it?
September 28th, 2010 - 14:51
Hi Rishi,
Have you granted the admin user you are trying to do this the appropriate role? You would do this using the following command, then close/open the Exchange Management Shell.
New-ManagementRoleAssignment –Role “Mailbox Import Export” –User
Steve
September 28th, 2010 - 15:11
Steve,
many thanks for the reply. I have checked the role assignment and this is fine. However for exampe running the cmdlet New-MailboxExportRequest i get the error:
[PS] C:\Windows\system32>New-MailboxExportRequest
The term ‘New-MailboxExportRequest’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
I cannot understand why these cmdlets have not been installed as part of the SP1 which i applied.
October 7th, 2010 - 11:13
Hi Rishi,
The following has been reported to solve this issue:
1) Launch Exchange powershell
2) Run “Add-pssnapin microsoft*”
3) Run “install-CannedRbacRoles”
4) Run “Install-CannedRbacRoleAssignments”
5) Close powershell
Steve
September 20th, 2010 - 16:18
All nodes running SP1, we are getting this exact error “Couldn’t connect to the source mailbox.”. Microsoft for now is calling it a bug. The only workaround is setting the “RpcClientAccessServer” to the CAS box on the database instead of the CAS Array. I did this for our test MB servers and just moved the mailbox I needed to export to the test mb server then moved it back. Note, doing this for production mailboxes will force a rebuild of the user’s Outlook profile since it is no longer connecting through the CAS Array while it’s on a db set to the CAS node.
September 20th, 2010 - 22:38
Hi Jon,
Do you have any SR# I can pass onto the MS people at my side looking at this to close the loop?
Steve
September 28th, 2010 - 17:00
We had a few cases open (not specifically to this) and a PFE on site for a few weeks looking at various issues. He researched this specific issue of importing/exporting behind a CAS array and found one other open case where the support engineer saw the same issue. I haven’t heard any word back on this yet.
September 28th, 2010 - 17:07
The one I’m looking at with another commenter isn’t behind a CAS array, but still waiting for RPCClientAccess traces so we can progress it.
Sadly, though, I’ve not been able to repro across at least 5 different SP1 environments so far. It would have been good if this could have been picked up pre-SP1 as it’s a pity some people are having problems.
Steve
September 15th, 2010 - 10:59
I now see that if I keep running the command the mailboxexport gets queued after 2 to 5 tries (never on the first) ?? No other changes – it just randomly failed
September 8th, 2010 - 10:22
i am using Exchange 2010 SP1 RTM and receiving following error:
Couldn’t connect to the source mailbox.
+ CategoryInfo : NotSpecified: (0:Int32) [New-MailboxExportRequest], RemotePermanentException
+ FullyQualifiedErrorId : DA7266AE,Microsoft.Exchange.Management.RecipientTasks.NewMailboxExportRequest
September 8th, 2010 - 22:14
Hi Abdul,
That’s strange. Is the mailbox you are exporting on an SP1 mailbox server?
Steve
September 9th, 2010 - 15:22
I’m seeing the same thing (initiated on a CAS/Hub 2010 SP1 server, targetting a mailbox on a 2010 SP1 server):
Couldn’t connect to the source mailbox.
+ CategoryInfo : NotSpecified: (0:Int32) [New-MailboxExportRequest], RemoteTransientException
+ FullyQualifiedErrorId : 2AA99EBD,Microsoft.Exchange.Management.RecipientTasks.NewMailboxExportRequest
We’re moving our users from Exchange 2007 to 2010 and have installed SP1 on the Exchange 2010 servers (downloaded just after it’s official release). We have migrated a few mailboxes over to Exchange 2010 and implemented a CAS array (just yesterday). I tried exporting my own account (before doing anyone else) but got the error above too.
My real reason for doing this was to test whether the account had to be on 2010 or if we could use it to export the pst files on the 2007 servers prior to migrating the users’ mailboxes. We have told the few that we have moved that they should back up their profile to a local PST file before we migrate their account. One person commented that it would be nice to provide that service as part of the migration steps but not require the users to do it (i.e. export to PST on the server prior to the migraiton). Based on your comment/question to Abdul re: SP1 mailbox server, I assume this is not possible.
Trevor
September 9th, 2010 - 17:06
Hi Trevor,
Yep, to use this method on 2010 SP1 , the mailbox does also need to be on 2010 SP1. Are you aware that on Exchange 2007 SP1-SP3 you can export Exchange 2007 mailboxes to PSTs using a 32-bit machine running Outlook 2007 plus the 32-bit Exchange 2007 Management tools?
Even so, it seems an unnecessary step to get them to backup to PST before moving their mailboxes. If the move fails, then their mailbox stays as is – it’s a copy then delete. DB level backups should be useful if you do have a major issue, and will restore in full fidelity.
Anyway – there is likely to be a reason for the problem you are having, it shoudln’t be those issues that showed up in Beta.
I would try it again with -Verbose, and if/when it fails, look at the output of
$Error[0].Exception.SerializedRemoteException.InnerException
and
$Error[0].Exception.SerializedRemoteException.InnerException.InnerException
If you want to go off-blog feel free to ping me at steve@goodman.net
Steve
September 14th, 2010 - 10:17
I’m also getting this error in my all SP1 environment.
I have sent you a dump of my -verbose result on mail
August 24th, 2010 - 14:03
Hi All,
I have a lab environment with the exact same problem. (Couldn’t connect to the source mailbox.)
My lab is build with a single server exchange installation. Anyone knows another couse for this error?
Regard,
Kees
August 24th, 2010 - 17:05
The cause is to do with Kerberos auth between MRS>CAS IIRC. If you have no CAS array enabled (you can still have enabled on single server) then you may have to hold tight for SP1 RTM
August 29th, 2010 - 20:28
Hiya,
If you haven’t already, upgrade to the SP1 RTM version that was released the other day
S
August 23rd, 2010 - 22:46
Hi Steve, I’m interested for a workaround, since I’m using CAS array in my lab.
Regards,
Andrija
August 23rd, 2010 - 23:24
Hi Andrija,
You have to remove the CAS array and replace it with a standalone CAS instead.
That’s not great – but SP1 when released doesn’t have this issue.
Steve
August 19th, 2010 - 20:58
Please to post workarround steps
August 19th, 2010 - 21:09
Hi Thomas,
The workaround is to get rid of the CAS array and replace it with a standalone CAS fronting the MDB.
This will be fixed in SP1 RTM though.
Steve
August 9th, 2010 - 14:41
Great post – I get this error:
Couldn’t connect to the source mailbox.
+ CategoryInfo : NotSpecified: (0:Int32) [New-MailboxExportRequest], RemoteTransientException
+ FullyQualifiedErrorId : B34FC71E,Microsoft.Exchange.Management.RecipientTasks.NewMailboxExportRequest
Do you know anything about this ?
August 9th, 2010 - 15:50
Yes. It’s a known big in the beta build and manifests itself mainly when there is a CAS array setup. It’s fixed in later builds and will be in RTW of SP1.
Easiest way to test out this feature before it’s released is to setup a multi-role server on it’s own. I can provide workaround steps if you need tho.
Steve
July 25th, 2010 - 23:23
nice post. thanks.
July 23rd, 2010 - 01:37
Great write-up! You and Henrik are neck and neck!
http://www.msexchange.org/articles_tutorials/exchange-server-2010/management-administration/look-import-export-mailbox-improvements-exchange-2010-service-pack-1-part1.html
Did your server have multiple roles installed or just the mailbox role? there was a bug with multiple roles and import-mailbox in 2010 RTM.
July 23rd, 2010 - 07:04
Hi Mike,
This was going to be an post covering all the features but yep, Henrik is publishing a much better multi-part article therefore I thought I’d focus on just the mass-export features.
Good point about the roles. That’s the very reason I’ve been holding back on posting this article – the lab environment I started writing this against has CAS, HT, DAG all on seperate servers, and includes a CAS array in the mix, so I hit a similar bug to the one you mention. Good news is that it’s fixed in newer builds and should hopefully stay fixed for SP1 RTW!
If you are trying this now on SP1 beta, it should be fine on a multi-role test box though.
Steve