Sunday, March 31, 2013

Exporting Exchange 2010 to PST & import back


Wanting to have a backup of user PSTS so I can import should other methods prove extraneous.

I've done windows backup, file level and NOT a disc image, due to UEFI and not being experienced enough to feel comfortable with that in production.

I want to export all users to a pst file for peace of mind, sanity and an alternative option that will be easier -- IE importing mailboxes into a new domain w/o giving a crap about preserving any of the old domain data.

Really, I want to avoid having to crap my pants when I realize that the last mailbox database name was done with a capital letter, typo, or the settings I'm trying to escape royally boned me.

This guide will walk you through , ultimately setting a script in motion to export all users from a database without any further intervention.

1. Set up the share to receive psts

Set up the shared folder,
create a folder  to be shared (I choose pst due to not having spaces in the path) and give "exchange trusted subsystem" both full security AND share priviledges -- I remove users, and add administrators and specifically the account i want to backup with.

make sure you can access the share

2. Discovering your Mailbox Database name:

I was having difficulties getting pointed to my mailbox. The name, according to other powershell guides I was following was to fqdn followed by "Mailbox Database" for the name, I couldn't get it to work with the server, it just wanted the domain - even then I had to bypass using guid

none of the commands would take what i thought it would be, or variations, so I found how to get the GUID which was accepted w/o fqdn  suspect database names

get-mailboxdatabase -storagegroup "First Storage Group" | fl 

Basically, when the script called for a database name, I used the guid.

I think it's not a fqdn and rather just a dn- fqdn means server included, so server.domain.local wasn't getting me there but domain.local would have. So I think it may have been just 'domain.extension\Mailbox Database'

3. Giving Permissions

Give the account you intend to run the backup from the correct priviledges by running this command
Change "-user administrator" to the username you intend to run the backups from

New-ManagementRoleAssignment –Role "Mailbox Import Export" –User Administrator

4. Run the script and wait

Open notepad and paste the following:

$mailboxes = get-mailbox
foreach ($mailbox in $mailboxes) {
new-mailboxexportrequest -mailbox $mailbox -FilePath \\server\pst\$mailbox.pst

Save the notepad file as a .ps1 - a powershell script.

Open the exchange console (powershell) and drag the script we just created in. It should appear w/o quotes around it and simply run.

You can check the status of the transfer  by typing


5. Importing:

After you've made your move, recreated the accounts, repeat steps 1-3

then run this powershell script

$mailboxes = get-mailbox
foreach ($mailbox in $mailboxes) {
new-mailboximportrequest -mailbox $mailbox -FilePath "\\server\shared\$mailbox.pst"


Further Jobs:
Find out reason for failure 
Get-MailboxExportRequest -status failed | Get-MailboxExportRequestStatistics -IncludeReport | Format-List > \\$server\$share\filename.txt

Making powershell able to run scripts

Allow scripts: Set-executionpolicy unrestricted 

Disable Scripts: Set-executionpolicy restricted 

Note, if you have any difficulty with the scripts, keep in mind they're not cut and paste - you're going to have to change the path to match your environment (IE "server" should be your servername, "shared", the folder you've shared.)

Sources, cites & credit due:

Setting up permissions, shares:

The Script to automate the exporting of users:

No comments:

Post a Comment