PowerShell Get Exchange 2007 Database used space

Aaron on http://powershellcommunity.org asked “I need to get a nice simple list of DB sizes based on how big the mailboxes are, not how big the .edb file is.
All of my DB’s are on 100gb disks. A particular EDB might be 90 gigs, but the database could have 40 gigs of whitespace in it. I want to be able to see how much actual space the database has consumed, not how big the file is on the disk. Does that make sense?”

He went on to say that “I really love your Exchange 2007 Mailbox Database Reporting Script. I was thinking it would be incredibly useful to add a column containing the info the command in this thread gives, then if you’re really feeling fancy you could subtract one from the other into another column to get a rough but fairly accurate white space measurement without digging through logs for event 1121 and parsing it out.”

Well, with that, how could I refuse to help 😉

That conversation led to this quick one liner to gather the total size of all items in all databases:

Get-MailboxServer | Get-MailboxDatabase |

Select Server, StorageGroupName, Name, @{Name="Size";expression={"{0:N2}" -f ((get-mailboxstatistics -database $_.Identity | Measure-Object -Property TotalItemSize,TotalDeletedItemSize -Sum |Select-Object Sum |Measure-Object -Property Sum -Sum).Sum.ToString() /1mb)}}

(Watch the word wrap, it’s all one line)

Give it a try, and let me know what you think.

  1. #1 by albertwt on February 24, 2011 - 17:12

    yes, it works really great and fast too.
    thank you for sharing your script here Karl !.

  2. #2 by Shree on May 2, 2013 - 08:21

    Amezing Script….Thanks

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: