Exchange – Move ‘ALL’ Mailboxes From One Database to Another

KB ID 0000864 

Problem

While replacing an Exchange Server on my test network last week, I needed to get all the mailboxes moved across to the new one. Exchange gets upset if you try and delete a mailbox database that has data in it.

Solution

1. Launch the Exchange Management Shell > Firstly lets get the names of my Databases, then I can simply copy and paste them into the move mailbox command.

[box]

Get-MailboxDatabase

Get-Mailbox -Database Source Database Name -ResultSize Unlimited | New-MoveRequest -TargetDatabase Target Database Name

[/box]

2. The Mailbox moves should then be queued, depending on how many there are, this can take some time to complete.

3. To check on progress issue the following command;

[box]

Get-MoveRequestStatistics -MoveRequestQueue Target Database Name

[/box]

 

4. When complete you should remove the movement requests like so;

[box]

Get-MoveRequest | where {$_.status -eq “Completed”} | Remove-MoveRequest

[/box]

5. That’s all the ‘user’ mailboxes, but your source database server may have system mailboxes in it. These will be either Arbitration mailboxes, or Archive Mailboxes (or both). I don’t have any archive mailboxes, but I do have Arbitration mailboxes. To find out for your databases, use the following commands;

[box]

Get-Mailbox -Database Source Database Name -Arbitration

[/box]

6. To move Arbitration and Archive mailboxes, use the following commands;

[box]

Get-Mailbox -Database Source Database Name -Arbitration | New-MoveRequest -TargetDatabase Target Database Name

Get-Mailbox -Database Source Database Name -Archive | New-MoveRequest -TargetDatabase Target Database Name

[/box]

7. You can monitor progress with the same command you used in step 3, and remove the move requests with the same command you used in step 4.

8. In addition you may also have some Auditlog mailboxes like so;

[box]

Get-Mailbox -Database Source Database Name -Auditlog | New-MoveRequest -TargetDatabase Target Database Name

[/box]

9. Also you may have Monitoring Mailboxes, (In the screenshot below you can see I don’t have any archive mailboxes, as the command returns no results)

[box]

Get-Mailbox -Database Source Database Name -Monitoring | New-MoveRequest -TargetDatabase Target Database Name

[/box]

10. When complete remove the move requests;

[box]

Get-MoveRequest -MoveStatus Completed | Remove-MoveRequest

[/box]

11. Finally on Exchange 2013 (and newer) you may also have Public Folder Mailbox(s).

[box]

Get-Mailbox -Database Source Database Name -PublicFolder | New-MoveRequest -TargetDatabase Target Database Name

[/box]

Don’t forget to remove any outstanding move requests.

Related Articles, References, Credits, or External Links

NA