When migrating from Exchange 2010 to Exchange 2013, it makes sense to distribute the mailboxes alphabetically to the new Exchange 2013 databases. I have therefore created a script that divides all mailboxes of a source database into the target databases according to the first letter of the name:
param
(
[string]$Database
,
[string]$Defaultdatabase
,
[bool]$CreateMoveRequest
)write-host “
Process mailboxes in database $database
—————————————————
“ -foregroundcolor greenif ($CreateMoveRequest)
{
write-host “ Postfächer werden verschoben und angezeigt!“ -foregroundcolor yellow
write-host „“}
else
{
write-host “ Postfächer werden nicht verschoben, nur angezeigt.“ -foregroundcolor green
write-host „“
}$mailboxlist = Get-Mailbox -database $database -ResultSize unlimited
foreach ($mailbox in $mailboxlist)
{
$displayname = $mailbox.displayname
switch -Regex ($displayname.substring(0,1))
{
„[A-C]“ {$mailboxdatabase = „A-C-Datenbank“}
„[D-F]“ {$mailboxdatabase = „D-F-Datenbank“}
„[G-J]“ {$mailboxdatabase = „G-J-Datenbank“}
„[K-L]“ {$mailboxdatabase = „K-L-Datenbank“}
„[M-O]“ {$mailboxdatabase = „M-O-Datenbank“}
„[S]“ {$mailboxdatabase = „S-Datenbank“}
„[T-Z]“ {$mailboxdatabase = „T-Z-Datenbank“}
default {$mailboxdatabase = „$defaultdatabase“}
}$currentmbxdatabase = $mailbox.database.name
if ($currentmbxdatabase -ne $mailboxdatabase)
{
if ($CreateMoveRequest)
{
$move = New-MoveRequest -Identity $mailbox -TargetDatabase $mailboxdatabase
}
Write-Host „$displayname wird in Datenbank $mailboxdatabase verschoben“
}}
write-host „“
The syntax is as follows (save script above in move-mailboxes.ps1):
move-mailboxes -database -defaultdatabase -createmoverequest $true
-Database specifies the source database
-DefaultDatabase specifies a default database if no match is found, for example if the name starts with a number
-$true directly generates the corresponding move requests, $false only indicates to which database the mailbox will be moved, but does not yet create a move request.