Useful techniques for enumerating mailboxes in Exchange 2003 using PowerShell

I stumbled across this old post by Jonathan Medd and thought I should make a note of it: Exchange 2003, WMI and Powershell – Part 1 (Get Mailbox Info)

Basically it’s a powershell command that will enumerate all the data in the Exchange stores of a 2003 environment.  I’m not sure if it works in 2007 and up, but I do still deal with 2003 and it gave me a few ideas which I thought I would share here:


# extracts the details of a specific user’s mailbox from the target server.

# takes the servername and the displayname of the user as parameters.

Get-WMIObject -namespace root\MicrosoftExchangeV2 -class Exchange_Mailbox -computer server | ?{$_.MailboxDisplayName -like "*$name*"} | sort-object MailboxDisplayName | format-table MailboxDisplayName,Servername,StorageGroupName,StoreName,Size



# generates a report about every mailbox on an exchange server in tab-separated format for easy import into excel.

# takes the servername as a parameter


$logfile = "$"

if(test-path $logfile){ri $logfile}

add-content $logfile "MailboxDisplayName`tServername`tStorageGroupName`tStoreName`tSize"

$mailboxes = Get-WMIObject -namespace root\MicrosoftExchangeV2 -class Exchange_Mailbox -computer $server | sort-object MailboxDisplayName
foreach($mailbox in $mailboxes)
    $name = $mailbox.MailboxDisplayName
    $mailsrv = $mailbox.Servername
    $sg = $mailbox.StorageGroupName
    $store = $mailbox.StoreName
    $size = $mailbox.Size
    add-content $logfile "$name`t$mailsrv`t$sg`t$store`t$size"

  1. No trackbacks yet.

Leave a Reply

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

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

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

%d bloggers like this: