Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

List of mailboxes on server sorted by mailbox size

Posted on 2012-08-14
7
Medium Priority
?
7,867 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
Looking for the Wi-Fi vendor that's right for you?

We know how difficult it can be to evaluate Wi-Fi vendors, so we created this helpful Wi-Fi Buyer's Guide to help you find the Wi-Fi vendor that's right for your business! Download the guide and get started on our checklist today!

 
LVL 9

Accepted Solution

by:
chrismerritt earned 2000 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.
1
 
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

If you troubleshoot Outlook for clients, you may want to know a bit more about the OST file before doing your next job. IMAP can cause a lot of drama if removed in the accounts without backing up.
There are times when we need to generate a report on the inbox rules, where users have set up forwarding externally in their mailbox. In this article, I will be sharing a script I wrote to generate the report in CSV format.
In this video we show how to create a Resource Mailbox in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: Navigate to the Recipients >> Resources tab.: "Recipients" is our default selection …
The basic steps you have just learned will be implemented in this video. The basic steps are shown to configure an Exchange DAG in a live working Exchange Server Environment and manage the same (Exchange Server 2010 Software is used in a Windows Ser…
Suggested Courses

721 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