header image

Archive for Exchange

Way back in the day – http://richardspowershellblog.wordpress.com/2007/12/20/list-mailboxes-by-mailbox-database/ – I showed how to list mailboxes by the database in which they were stored.  I had a comment left asking if its possible to list only a specific mailbox and to give the mailbox size as well.

To recap:

Get-Mailbox will return the list of mailboxes

This will quickly show the number of mailboxes per database

Get-Mailbox | group Database –NoElement

This shows the mailboxes in a particular database

Get-Mailbox -Database MDB1

To get the size you use Get-MailboxStatistics

So to put this together:

function get-mbxBYdb {
param (

Get-Mailbox -Database $database |
foreach {
$stat = $_ | Get-MailboxStatistics -WarningAction SilentlyContinue
New-Object -TypeName PSObject -Property @{
   Name = $($_.DisplayName)
   Address = $($_.PrimarySmtpAddress)
   Database = $database
   Items = $stat.ItemCount
   ‘Size(KB)’ = $stat.TotalItemSize.Value.ToKB()



The database name is a mandatory parameter.  Get the mailboxes in the database and foreach get the mailbox statistics.  You can then create an output object that combines the data from the mailbox object and the statistics object.  Examine each type of object individually to determine the exact set of properties you need.

One trick with the size of items is that you can convert to specific size units as shown (MB, GB, TB and bytes are also available)

under: Exchange, PowerShellV2

New-mailbox oddity

Posted by: | July 2, 2013 | No Comment |

I’ve been doing a lot with Exchange recently and found an interesting quirk.

If you use the New-mailbox cmdlet with the –PrimarySMTPaddress parameter the mailbox doesn’t get email address policies applied.

You need to use set-mailbox to turn policy application on – after the mailbox has finished creating

under: Exchange, PowerShell original