Wednesday, 25 November 2015

Exchange 2016 Mailbox Database Whitespace

You can use either the Get-MailboxDatabase cmdlet or eseutil to figure out how much whitespace there is in your Exchange 2010, 2013 or 2016 mailbox database. Below I’ll demonstrate how to use both methods.


Get-MailboxDatabase


If we run the Get-MailboxDatabase cmdlet with the status switch, we can get an estimate of whitespace.

Get-MailboxDatabase "Mailbox Database 1051570769" -Status | fl Name,AvailableNewMailboxSpace

image

Here we can see an estimate of 105.1MB of whitespace in the database.


Eseutil /ms


The most accurate method is to use eseutil with the /ms switch. The /m switch specifies that we want to run eseutil in file dump mode where we will get attributes of various files. The /m mode includes a modifier and in our case we will use ‘s’ which dumps the space usage of the database.

The disadvantage is this command requires the database to be offline.

1) Dismount the database by running this command:

Dismount-Database "Mailbox Database 1051570769" -Confirm:$false

2) Run the eseutil /ms command:

eseutil /ms “C:\Program Files\Microsoft\Exchange Server\V15\Mailbox\Mailbox Database 1051570769\Mailbox Database 1051570769.edb”

3) Mount your database again:

Mount-Database "Mailbox Database 1051570769" -Confirm:$false

Below you can see all three commands running in one go which only dismounts the database for a few seconds:

image

There’s a lot more information when using eseutil but I’ve highlighted the whitespace which is 105.063MB. You can see that the operation completed successfully in 2 seconds to run so you don’t need much downtime for this.

Automating eseutil /ms

I think I have a bit of a problem in that whenever I see more than one PowerShell command, I have to write it into a function. Here goes then. This function will get the whitespace for a particular mailbox database that you specify. It also works out the mailbox database path and passes this to eseutil so you only need to tell it the database name. Ensure you use a database on the same server as you’re running the command as eseutil can’t run remotely.

1) Copy the below function and paste into your Exchange Management Shell window:

function Get-MailboxDatabaseWhiteSpace
    {
        Param(
        [Parameter(Mandatory = $true)]
        [string] $Database
        )

        $MDB = Get-MailboxDatabase $Database
        Write-Host Dismounting $Database -ForegroundColor Green
        Dismount-Database $MDB -Confirm:$false
        eseutil /ms $MDB.EdbFilePath
        Write-Host Mounting $Database -ForegroundColor Green
        Mount-Database $MDB
    }


2) Run the function using the command below:

Get-MailboxDatabaseWhiteSpace -Database "Mailbox Database 1051570769"

image

Now you know how to accurately figure out how much whitespace you have.

No comments:

Post a Comment