How many users per mailbox database
Filed in Powershell on Sep.19, 2008
This script prints out each database and gives a count of how many users on each database
###
clear-host
write-host -fore yellow “This script will get each mailboxdatabase and the current user count “
foreach($name in get-mailboxdatabase)
{
write-output “$name”
$count=(get-mailbox -database $name).count
if($count -eq $null)
{ write-host -fore red “Empty Database, no users”
}
else
{ write-output $count }
}
write-host -fore yellow “The system has a total of “$user=(get-mailbox – resultsize:unlimited).count
write-host -fore red $user

![[Google]]( http://www.exchange-genie.com/wp-content/plugins/easy-adsense-lite/google-light.gif)




September 19th, 2008 at 8:41 am
Very nice; thanks Genie.
September 30th, 2008 at 2:36 am
thanks, usefull.
Fyi:
A litte error in your script when copying it. There is a “space” between the “-” and “-resultsize:unlimited).count”. This end with an error
Bruno
September 30th, 2008 at 3:49 am
thanks, must have happened in the copy paste
October 8th, 2008 at 8:52 am
Great Script…Could you please tell us to how to get the result to a .csv file?
October 8th, 2008 at 5:57 pm
You can just pipe it to the export-csv command..
http://technet.microsoft.com/en-us/library/bb978597.aspx
October 20th, 2008 at 2:39 pm
Hi – Where can I get more such scripts….thanks again
October 20th, 2008 at 8:01 pm
I would say just search on the web, what are you looking for?
November 13th, 2008 at 3:09 am
Its so freaking cool.
Thanks.
November 24th, 2008 at 1:09 pm
Hi, thanks for the script. It has an error.
If there is only 1 mailbox in the Mailbox Database it says “Empty Database, no users”
Any idea why?
Thanks again,
Kaveh
November 24th, 2008 at 7:56 pm
I have not seen that happen, is the mailbox a system mailbox or user?
November 25th, 2008 at 9:44 am
It’s a user mailbox.
I’m using Exchange 2007 without SP1 (I don’t know if that makes a difference)
I made a Storage Group
I made a Mailbox Database in it.
I made a User Mailbox in the Database.
I ran the script and it says it’s empty.
November 25th, 2008 at 11:24 am
run this get-mailbox -database youdbnamehere
and see what you get….
November 25th, 2008 at 12:44 pm
It shows the Name, Alias, ServerName and ProhibitSendQuota of the one person in the DB…
So for you it works fine? What version of Exchange and Powershell do you have? Maybe that’s the difference?
November 25th, 2008 at 7:48 pm
Don’t believe there was any changes since RTM with those commands however I am now on Sp1 RU5 if you are not on SP1 RU5 you really need to upgrade as there are hundreds of fixes and new features added in SP1 to make life easier
December 2nd, 2008 at 2:11 pm
Ya, I need to install the SP1 update. I’ll probably do that when we close for Christmas holidays. Is it straight forward to install?
Our Exchange 2007 environment is clustered so I can upgrade half the servers, flip control, and upgrade the other half.
December 2nd, 2008 at 8:28 pm
simple to do… for a cluster you upgrade the passive node, then fail over… it will fails then you up setup /upgradecms and it will come online then do the former active and now passive node…
note do the CAS servers first… fyi there are 5 rollups to sp1 already so you are pretty far back on your patching.
February 11th, 2010 at 5:30 pm
Hi, Can you please modify the script so that it won’t show the hidden mailboxes?
Mainly talking about msExchHideFromAddressLists=TRUE attribute..
August 3rd, 2011 at 4:06 pm
Hi, thanks for the script.
Only the parameter “–resultsize:unlimited” should also be added at line 7. Otherwise databases with more then 1000 users will stop counting. (i know, not a good practise that many users
)
$count=(get-mailbox -database $name –resultsize:unlimited).count
Thanks!
Wilbert