Powershell – Mailboxes moved and whitespace isn’t increasing… aka logical mailbox space not being freed

databaseexchange-2010powershell

I understand the difference between "logical" and "physical" free space and have a problem with whitespace not increasing (logical space, formerly event 1221 in Exchange 2003).

Given that

  • I have an Exchange 2010 server that had many mailboxes moved to a different databases.
  • Attachments are being deleted from messages

I observe that

  • When I run the script below no logical space is freed
  • When I run online maintenance, a full backup, or the powershell command clean mailbox database, nothing seems to free logical space.

For clarification, I'm not talking about disk space. I'm talking about whitespace within the database.

How can I free up logical space to a point where physical disk space is no longer being consumed (excluding log files)?

Because the wrong answer is being upvoted, and my question gets zero votes, I assume that people think I'm talking about physical space… but I'm clearly not

$Databases = Get-MailboxDatabase -Status
    foreach($Database in $Databases) {
        $DBSize = $Database.DatabaseSize

        $MBCount = @(Get-MailboxStatistics -Database $Database.Name).Count
        $AllMBStats = Get-MailboxStatistics -Database $Database.Name   

        $MBItemAssocCount = $AllMBStats   |   %{$_.AssociatedItemCount.value} |  Measure-Object -Average   -Sum
        $MBDeletedCount =   $AllMBStats   |   %{$_.DeletedItemCount.value} |  Measure-Object -Average   -Sum
        $MBItemCount =      $AllMBStats   |   %{$_.ItemCount} |  Measure-Object   -Sum

        $MBDeletedItemSize= $AllMBStats   |   %{$_.TotalDeletedItemSize.value } |  Measure-Object -Average  -Sum
        $MBItemSize   =     $AllMBStats   |   %{$_.TotalItemSize.value.ToMb()} |  Measure-Object -Average    -Sum      

        New-Object PSObject -Property @{
            Server = $Database.Server.Name
            DatabaseName = $Database.Name

            UserCount = $MBCount

            "DatabaseSize (GB)" = $DBSize.ToGB()
            "DatabaseSize Deleted (bytes)" = $MBDeletedItemSize.Sum
            "WhiteSpace (MB)" = $Database.AvailableNewMailboxSpace.ToMB()
            "LogicalSize (MB)" =   $MBItemSize.Sum
            "Available Mailbox Space" =  $Database.AvailableNewMailboxSpace
            ItemCount = $MBItemCount.Sum
            "AverageMailboxSize (MB)" =  $MBItemSize.Average
    }
}

Best Answer

Exchange 2010 doesn't free up whitespace automatically. You either have to live with it, or create a new database and move all of the left-over accounts and delete the database.

EDIT: I forgot that if you don't mind dismounting your database and you have a bunch of free disk space available (equal to amount of whitespace) then you can do an offline defrag using eseutil /d. See http://exchangeserverpro.com/defrag-exchange-2010-mailbox-database

Related Topic