Solved

List of mailboxes on server sorted by mailbox size

Posted on 2012-08-14
7
7,421 Views
1 Endorsement
Last Modified: 2012-08-25
I have an Exchange 2007 server named Exch1.domain.com. It has about 2000 mailboxes.

I need a list of mailboxes on this server, sorted by size (MB), that includes:

DisplayName
Alias
Email Address

I should also be able to export this to CSV.

Any ideas how to do this in Powershell?
1
Comment
Question by:richlionel
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 13

Expert Comment

by:Xaelian
ID: 38292818
Can you try:

Get-MailboxStatistics | Sort-Object TotalItemSize -Descending | ft DisplayName,@{label="TotalItemSize(MB)";expression={$_.TotalItemSize.Value.ToMB()}}, Alias, PrimarySmtpAddress
0
 
LVL 52

Expert Comment

by:Manpreet SIngh Khatra
ID: 38292846
Get-Mailbox | Get-MailboxStatistics | Sort totalitemsize -desc | ft displayname, totalitemsize, itemcount

get-mailbox | get-mailboxstatistics | select-object displayname, itemcount,  lastloggedonuser, lastlogontime, lastlogofftime, servername, databasename, @{ expression={$_.TotalItemSize.Value.ToKB()} }

- Rancy
0
 
LVL 13

Expert Comment

by:Xaelian
ID: 38292896
Full command to csv:

Get-MailboxStatistics | Sort-Object TotalItemSize -Descending | ft DisplayName,@{label="TotalItemSize(MB)";expression={$_.TotalItemSize.Value.ToMB()}}, Alias, PrimarySmtpAddress|export-csv C:\stats.csv
1
Edgartown IT Case Study

Learn about Edgartown's quest to ensure the safety and security of the entire town's employee and citizen data. Read the case study!

 
LVL 9

Accepted Solution

by:
chrismerritt earned 500 total points
ID: 38294118
I'm going to take a different tactic here, some of the fields you want are in the Get-Mailbox command, some are in the Get-MailboxStatistics command, so you really want to combine them.

My script gets the mailboxes, then loops through each and adds in the Mailbox Size value in Mb. Then it sorts by this field descending, and selects the values you asked for.

I think this does what you want quite elegantly and in an easy-to-understand fashion. Set the -ResultSize parameter to "Unlimited" once you've tested it.

$Mailboxes = Get-Mailbox -ResultSize 20
foreach ($Mailbox in $Mailboxes)
{
	$Mailbox | Add-Member -MemberType "NoteProperty" -Name "MailboxSizeMB" -Value ((Get-MailboxStatistics $Mailbox).TotalItemSize.Value.ToMb())
}
$Mailboxes | Sort-Object MailboxSizeMB -Desc | Select DisplayName, Alias, PrimarySMTPAddress, MailboxSizeMB

Open in new window

To export the data just change the last line to:

$Mailboxes | Sort-Object MailboxSizeMB -Desc | Select DisplayName, Alias, PrimarySMTPAddress, MailboxSizeMB | Export-Csv -NoType "C:\Mailboxes.csv"

Open in new window

4
 
LVL 9

Expert Comment

by:chrismerritt
ID: 38307519
@richlionel - One of my problems with Experts Exchange is when you put time and effort into helping someone who is asking a question and they don't even acknowledge it or anything. Please don't do this.

3 of us have tried to help you, please either mark one or more of the answers as the right ones sharing the points out, or instead let us know if you need more help.
0
 
LVL 52

Expert Comment

by:Manpreet SIngh Khatra
ID: 38307561
chrismerritt: I agree totally with you :)
richlionel: As said it very Important you share your feedback so that if something isnt working we can try to tweek and assist you :)

- Rancy
0
 

Author Comment

by:richlionel
ID: 38332896
I apologise, I was ill for a few days.

I really appreciate the help from everyone in answering! I marked ChrisMerrit's answer as the correct one since that is the one I used and it did exactly what I wanted quite well.  I hope that is the right way to do things (I'm quite new to EE).

But, everyone, thanks again! I appreciate EVERYONE's input.
0

Featured Post

Office 365 Training for Admins - 7 Day Trial

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After hours on line I found a solution which pointed to the inherited Active Directory permissions . You have to give/allow permissions to the "Exchange trusted subsystem" for the user in the Active Directory...
Check out this step-by-step guide for using the newly updated Experts Exchange mobile app—released on May 30.
In this video we show how to create a Contact in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Recipients >> Contact ta…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question