Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

List of mailboxes on server sorted by mailbox size

Posted on 2012-08-14
7
Medium Priority
?
8,218 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
  • 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
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 
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

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

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

In this post, I will showcase the steps for how to create groups in Office 365. Office 365 groups allow for ease of flexibility and collaboration between staff members.
If you have come across a situation where you need to find some EDB mailbox recovery techniques, then here you will find the same. In this article, we will take you through three techniques using which you will be able to perform EDB recovery. You …
The video tutorial explains the basics of the Exchange server Database Availability groups. The components of this video include: 1. Automatic Failover 2. Failover Clustering 3. Active Manager
This video demonstrates how to sync Microsoft Exchange Public Folders with smartphones using CodeTwo Exchange Sync and Exchange ActiveSync. To learn more about CodeTwo Exchange Sync and download the free trial, go to: http://www.codetwo.com/excha…

927 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