Check Exchange Database Size with PowerShell scripting


To totally unlock this section you need to Log-in


Login

Checking your Exchange database size in PowerShell is key in several scripting scenarios, such as creating mailboxes in the smallest database, or generating basic database reports. The problem in Exchange 2007 was that this was a lot harder than it sounded.

The Get-MailboxDatabase cmdlet did not return the size of the database. If you needed to determine the database size, you had to write some fairly lengthy code to get what you think would be be easily accessible information.

Exchange 2007

There are a couple methods you can use to get this information in Exchange 2007. Here is a great example posted by Gary Siepser; it’s a one-liner that retrieves the database size using WMI, allowing you to run it against clustered mailbox servers:

Get-MailboxDatabase | foreach-object {add-member -inputobject $_ -membertype noteproperty -name mailboxdbsizeinGB -value ([math]::Round(([int64](get-wmiobject cim_datafile -computername $_.server -filter (‘name=”’ + $_.edbfilepath.pathname.replace(“\”,”\\”) + ””)).filesize / 1GB),2)) -passthru} | Sort-Object mailboxdbsizeinGB -Descending | format-table identity,mailboxdbsizeinGB

Exchange 2010

Fortunately, the Get-MailboxDatabase cmdlet in Exchange 2010 provides this information for us out of the box. All you need to do is use the Status parameter and you can access the information using the DatabaseSize property. Here is an example:

Get-MailboxDatabase -Status | select ServerName,Name,DatabaseSize
Check Exchange Database Size with PowerShell scripting

Check Exchange Database Size with PowerShell scripting

SOURCE

LINK

LANGUAGE
ENGLISH

1 thought on “Check Exchange Database Size with PowerShell scripting”

Comments are closed.