Using the Exchange 2010 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, SP2 and SP3, 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:

image

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:

image

1
New-ManagementRoleAssignment –Role “Mailbox Import Export” –User AD\Administrator

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:

image
1
New-MailboxExportRequest -Mailbox Administrator -FilePath "\\AZUA\Exports\Administrator.pst"

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:

image

1
Get-MailboxExportRequest | Get-MailboxExportRequestStatistics

After the requests complete, you can remove the requests in a similar fashion, using the Remove-MailboxExportRequest command:

image

1
Get-MailboxExportRequest | Remove-MailboxExportRequest
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:

image

1
foreach ($i in (Get-Mailbox)) { New-MailboxExportRequest -Mailbox $i -FilePath "\\AZUA\Exports\$($i.Alias).pst" }

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?

image

1
foreach ($i in (Get-Mailbox | Where {$_.ExchangeVersion.ExchangeBuild.Major -eq 14})) { New-MailboxExportRequest -Mailbox $i -FilePath "\\AZUA\Exports\${$i.Alias).pst" }

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:

image

1
foreach ($i in (Import-Csv .\exports.csv)) { New-MailboxExportRequest -Mailbox $i.Alias -FilePath "\\AZUA\Exports\$($i.Alias).pst" }
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!

1
2
# Exchange 2010 SP1 Mailbox Export Script
# Steve Goodman. Use at your own risk!

###############
# Settings #
###############

# Pick ONE of the two below. If you choose both, it will use $Server.
$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 = “\\server\share”

# 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 = “\\server\share”

# 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 = $false

###############
# Code #
###############

if ($Server)
{
if (!(Get-ExchangeServer $Server -ErrorAction SilentlyContinue))
{
throw “Exchange Server $Server not found”;
}
if (!(Get-MailboxDatabase -Server $Server -ErrorAction SilentlyContinue))
{
throw “Exchange Server $Server does not have mailbox databases”;
}
$Mailboxes = Get-Mailbox -Server $Server -ResultSize Unlimited
} elseif ($Database) {
if (!(Get-MailboxDatabase $Database -ErrorAction SilentlyContinue))
{
throw “Mailbox database $Database not found”
}
$Mailboxes = Get-Mailbox -Database $Database
}
if (!$Mailboxes)
{
throw “No mailboxes found on $Server”
}

if (!$Mailboxes.Count)
{
throw “This script does not support a single mailbox export.”
}

# Pre-checks done

# Make batch name
$date=Get-Date
$BatchName = “Export_$($date.Year)-$($date.Month)-$($date.Day)_$($date.Hour)-$($date.Minute)-$($date.Second)”

Write-Output “Queuing $($Mailboxes.Count) mailboxes as batch ‘$($BatchName)'”

# Queue all mailbox export requests
foreach ($Mailbox in $Mailboxes)
{

if ($RemovePSTBeforeExport -eq $true -and (Get-Item “$($ExportShare)\$($Mailbox.Alias).PST” -ErrorAction SilentlyContinue))
{
Remove-Item “$($ExportShare)\$($Mailbox.Alias).PST” -Confirm:$false
}
New-MailboxExportRequest -BatchName $BatchName -Mailbox $Mailbox.Alias -FilePath “$($ExportShare)\$($Mailbox.Alias).PST”
}

Write-Output “Waiting for batch to complete”

# Wait for mailbox export requests to complete
while ((Get-MailboxExportRequest -BatchName $BatchName | Where {$_.Status -eq “Queued” -or $_.Status -eq “InProgress”}))
{

sleep 60
}

# Write reports if required
if ($ReportShare)
{
Write-Output “Writing reports to $($ReportShare)”
$Completed = Get-MailboxExportRequest -BatchName $BatchName | Where {$_.Status -eq “Completed”} | Get-MailboxExportRequestStatistics | Format-List
if ($Completed)
{
$Completed | Out-File -FilePath “$($ReportShare)\$($BatchName)_Completed.txt”
}
$Incomplete = Get-MailboxExportRequest -BatchName $BatchName | Where {$_.Status -ne “Completed”} | Get-MailboxExportRequestStatistics | Format-List
if ($Incomplete)
{
$Incomplete | Out-File -FilePath “$($ReportShare)\$($BatchName)_Incomplete_Report.txt”
}
}

# Remove Requests
Write-Output “Removing requests created as part of batch ‘$($BatchName)'”
Get-MailboxExportRequest -BatchName $BatchName | Remove-MailboxExportRequest -Confirm:$false

Command file contents:

1
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -command ". 'c:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1'; Connect-ExchangeServer -auto; .\MassExport.ps1"

Download as ZIP

292 thoughts on “Using the Exchange 2010 Mailbox Export features for Mass Exports to PST files

    • Hiya

      This should be possible if you add a line to the script similar to this:

      1
      Send-MailMessage -To you@example.com -From you@example.com -Subject "Export Completed Report" -Body "Report Attached" -SmtpServer smtp.example.com -Attachments "$($ReportShare)\$($BatchName)_Completed.txt"

      Steve

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

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

    • 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

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

    • 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

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

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

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

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

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

  8. Pingback: power-shell.com.au | Exporting Mailboxes Exchange 2010 SP1

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

    • 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

  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”}))

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

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

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

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

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

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

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

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

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

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

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

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

      • 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

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

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

  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

        • 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” }

  24. 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 0x41301 (task running) for 10 minutes and then 0x1 (bad…)

    I’ve scheduled de MassExport.cmd

    Can someone help me ?

    Donovan
    (I speak french, sorry if my english is bad 😉

    • 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

      • 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

      • Hi Steve,

        I tried to run MassExport.cmd from de CMD and everything is working perfectly…

        Have you got any other ideas ?

        Donovan

        • 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

          • Hello !

            add the path in the MassExport.cmd did work fine 😉

            Thank you very much !

            Donovan

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

  26. Pingback: FamousPhil.com Admin Blog and More :: A Decent Backup Strategy for Exchange 2010 SP1

  27. Pingback: 2010 roundup and first blog anniversary… | Steve Goodman's Tech Blog

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

    • 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

    • “- The mailbox is enabled (mapi)” did solve my “Couldn’t connect to the source mailbox” error on a multi-role box.

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

    • 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

        • 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

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

    • 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

      • 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!!!

          • 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!

      • 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 🙁

        • 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

  31. Pingback: Export PST bei Exchange 2010 SP1 » Exchange » TechGuy

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

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

    • 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

      • 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

        • 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

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

    • 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

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

        • 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

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

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

        • 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

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

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

      • 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

        • 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

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

    • 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

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

    • 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

  40. Pingback: Google Calendar Syncing with iCal in Snow Leopard | Apple On The Longtail

    • 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

  41. Pingback: Tweets that mention Using the Exchange 2010 SP1 Mailbox Export features for Mass Exports to PST files « Steve Goodman's Tech Blog – The weblog of an IT pro specialising in Exchange, Exchange, VMware, Servers and Storage -- Topsy.com

Comments are closed.