Udostępnij za pośrednictwem


Exchange: Non-Discriminant Mailbox Moves

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
 }
 else
 {
  New-MoveRequest $MBXs[$y].Identity -TargetDatabase EURPROD01-db002
 }
}

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

Comments

  • Anonymous
    November 10, 2014
    cool stuff
    thanks