Exchange: Non-Discriminant Mailbox Moves

NOTE: This post – drafted, composed, written, and published by me – originally appeared on and is potentially (c) Microsoft.

I had to rebuild my lab and in one of the invariable problems of doing this is that the default database is created and by the time you do any administration in Exchange, mailboxes exist on it.

I had to come up with a sure-fire way to balance moves between the two mount-points I had created, so as to not really favor one over the other (plus, manually alternating isn’t much fun).

Enter PowerShell. First, I had to make script to test if the iteration I was on was even or odd:

function Check-IfEvenOrOdd ($digit) {[bool]!($digit%2)}

Once I had the function, the next step was to iterate:

$MBXs = @()
$MBXs += Get-Mailbox -Database “Mailbox Database 1750300935”
$MBXs += Get-Mailbox -Database “Mailbox Database 1750300935” -Monitoring
$MBXs += Get-Mailbox -Database “Mailbox Database 1750300935” -Arbitration
$MBXs += Get-Mailbox -Database “Mailbox Database 1909919934” -Monitoring
$MBXs += Get-Mailbox -Database “Mailbox Database 1909919934” -Arbitration
($MBXs | Measure-Object).Count

for([int]$y = 0; $y -le 18; $y++)
 if(Check-IfEvenOrOdd $y = $true)
  New-MoveRequest $MBXs[$y].Identity -TargetDatabase EURPROD01-db001
  New-MoveRequest $MBXs[$y].Identity -TargetDatabase EURPROD01-db002

And there you have it: Easy ‘balancing’ of mailbox moves to evacuate databases.

One thought on “Exchange: Non-Discriminant Mailbox Moves

Comments are closed.