Solved

How do I make alist of the mailbox'es based on size?

Posted on 2010-11-23
11
1,315 Views
Last Modified: 2012-05-10
I want to make a list of all the mailboxes in a database, and I want to sort it decending based on the size of the mailboxes. In Exchange 2003 you could do this in the GUI, but no more for some reason. So I found a commando that should do this: "Get-MailboxStatistic -Database "DBname"

But it doesnt list the size of the mailboxes. I found out how to do this in Exchange 2007: [PS] C:\Windows\system32>Get-MailboxStatistics |ft DisplayName,TotalItemsSize,ItemCount,StorageLimitStatus

But this doesnt work in Exchange 2010. When I try I get a response asking about which mailbox I wish to list:

cmdlet Get-MailboxStatistics at command pipeline position 1
Supply values for the following parameters:
Identity:


The problem is that I want to include ALL the mailboxes in the DB. So how do I do this?
0
Comment
Question by:NAF-Data
11 Comments
 
LVL 33

Expert Comment

by:Busbar
Comment Utility
you will need to do:
get-mailbox -database dbname | Get-MailboxStatistics |ft DisplayName,TotalItemsSize,ItemCount,StorageLimitStatus
0
 

Author Comment

by:NAF-Data
Comment Utility
Im I typing wrong here? I dont get any result

[PS] C:\Windows\system32>Get-Mailbox -database DB01 |Get-MailboxStatistics|ft DisplayName,TotalItemSize,ItemCount,StorageLimitStatus
[PS] C:\Windows\system32>
0
 
LVL 25

Expert Comment

by:Tony1044
Comment Utility
Try this:

Get-MailboxStatistics | where {$_.ObjectClass –eq “Mailbox”} | Sort-Object TotalItemSize –Descending | ft @{label=”User”;expression={$_.DisplayName}},@{label=”Total Size (MB)”;expression={$_.TotalItemSize.Value.ToMB()}},@{label=”Items”;expression={$_.ItemCount}},@{label=”Storage Limit”;expression={$_.StorageLimitStatus}} -auto

Or if they're monsters you could change to show in GB:

Get-MailboxStatistics | where {$_.ObjectClass –eq “Mailbox”} | Sort-Object TotalItemSize –Descending | ft @{label=”User”;expression={$_.DisplayName}},@{label=”Total Size (GB)”;expression={$_.TotalItemSize.Value.ToGB()}},@{label=”Items”;expression={$_.ItemCount}},@{label=”Storage Limit”;expression={$_.StorageLimitStatus}} -auto
0
 
LVL 10

Expert Comment

by:abhijitmdp
Comment Utility
Use below command from EMC or powershell

Get-MailboxStatistics | where {$_.ObjectClass –eq “Mailbox”} |Sort-Object DisplayName | ft @{label=”User”;expression={$_.DisplayName}},@{label=”Total Size (MB)”;expression={$_.TotalItemSize.Value.ToMB()}} | out-file C:\MailboxList.csv

This will generate a csv file in your c:
0
 

Author Comment

by:NAF-Data
Comment Utility
Something is wrong, I still dont get any output. I tried both tip:

[PS] C:\Windows\system32>Get-MailboxStatistics | where {$_.ObjectClass -eq "Mailbox"} | Sort-Object TotalItemSize -Desce
nding | ft @{label="User";expression={$_.DisplayName}},@{label="Total Size (MB)";expression={$_.TotalItemSize.Value.ToMB
()}},@{label="Items";expression={$_.ItemCount}},@{label="Storage Limit";expression={$_.StorageLimitStatus}} -auto


cmdlet Get-MailboxStatistics at command pipeline position 1
Supply values for the following parameters:
Identity:



---------------------------------------------------------



[PS] C:\Windows\system32>Get-MailboxStatistics | where {$_.ObjectClass -eq "Mailbox"} |Sort-Object DisplayName | ft @{la
bel="User";expression={$_.DisplayName}},@{label="Total Size (MB)";expression={$_.TotalItemSize.Value.ToMB()}} | out-file
 C:\MailboxList.csv


cmdlet Get-MailboxStatistics at command pipeline position 1
Supply values for the following parameters:
Identity:
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 70

Expert Comment

by:Chris Dent
Comment Utility
Hello there,

You want this:
Get-Mailbox | Get-MailboxStatistics | Sort-Object TotalItemSize -Descending | 
  Select-Object DisplayName, TotalItemSize, ItemCount, StorageLimitStatus | Export-Csv "MailboxList.csv" -NoTypeInformation

Open in new window

HTH

Chris
0
 
LVL 70

Expert Comment

by:Chris Dent
Comment Utility

Sorry, you wanted a specific database, didn't you?
Get-MailboxStatistics -Database "Some Database" | Sort-Object TotalItemSize -Descending | 
  Select-Object DisplayName, TotalItemSize, ItemCount, StorageLimitStatus | Export-Csv "MailboxList.csv" -NoTypeInformation

Open in new window

Chris
0
 

Author Comment

by:NAF-Data
Comment Utility
I get a .csv file, but it is only 1 Kb. I open it in Excel and it only fills some weird signs in the first cell. Nothing more. I suspect something is wrong here, but I dont understand what. I have 4 mailservers, 2 HUB/CAS and 2 MBX. divided into 2 different sites, all of the servers are Exchange 2010 that I have upgraded to SP1, and they run on Windows 2008 R2. I run the script on the MBX server in Site A where the database is active. Any chance of this making some problem?
0
 
LVL 70

Accepted Solution

by:
Chris Dent earned 500 total points
Comment Utility

Nope, that should be fine. You used the version with Export-CSV above? Perhaps run this first and make sure you get something back:
Get-MailboxStatistics -Database "Some Database" | Sort-Object TotalItemSize -Descending | 
  Select-Object DisplayName, TotalItemSize, ItemCount, StorageLimitStatus

Open in new window

Chris
0
 

Author Comment

by:NAF-Data
Comment Utility
That worked, dont know why the other didnt. Now I got a decending list based on the size. Thnx
0
 
LVL 70

Expert Comment

by:Chris Dent
Comment Utility

With Export-Csv as well?

Chris
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article will help you understand what HashTables are and how to use them in PowerShell.
Scam emails are a huge burden for many businesses. Spotting one is not always easy. Follow our tips to identify if an email you receive is a scam.
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…
To show how to generate a certificate request 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 Servers >> Certificates…

744 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now