Redistribute mailboxes

Dec 16, 2020 13:05


function Move-TopMboxes {

[CmdletBinding()]

param (

[parameter(mandatory)][string]$SourceDB

)

$TargetDBs = Get-MailboxDatabase -Status | where {$_.Name -notlike "sys*"} | select Name,DatabaseSize | sort-object DatabaseSize

$mboxes = Get-Mailboxdatabase $SourceDB | Get-MailboxStatistics | Sort-Object TotalItemSize -Descending | Select-Object displayname,TotalItemSize -First 96

for ($i = 0; $i -lt 93; $i++)

{

New-MoveRequest  $mboxes[$i].displayname -TargetDatabase $TargetDBs[$i].name -WhatIf

}

}

$result = Move-TopMboxes "dag1-db02"
Previous post
Up