Powershell - get total size of maliboxes from a particular AD Organizational Unit?

I am looking to run a command within Exchange Powershell that allows me to gather only the total size of all mailboxes combined, for all mailboxes that live in an OU. The OU also has nested OU's as well so I'd need to include Mailboxes recursively within this OU.

Here's the command I got so far, I'm just not sure if it's getting nested mailboxes within the OU, and I'm not sure how to not report out each individual mailbox, but instead just calculate the total of all of them together?    

Also this is Exchange 2007 but some mailboxes within the OU live in Exchange 2010, but I think this reports accurately on those as well.

Get-Mailbox | where {$_.DistinguishedName -like "*OU=IT,OU=Business,OU=Cafe,DC=cafenet,DC=com*"} | Get-MailboxStatistics | Add-Member -MemberType ScriptProperty -Name TotalItemSizeinMB -Value {$this.totalitemsize.value.ToMB()} -PassThru | Format-Table DisplayName,TotalItem*

Open in new window


Or if there's an easier way within the Exchange Management Console that could work as well.
garryshapeAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Minecraft_ EndermanCommented:
To get the users in a particular AD Organizational Unit, we can use the –OrganizationalUnit and -DomainController parameter.

Get-Mailbox -OrganizationalUnit <OrganizationalUnitIdParameter> -DomainController <Fqdn> | Get-MailboxStatistics | Select-Object DisplayName, TotalItemSize | export-csv C:\report.csv

Refer from:
https://technet.microsoft.com/zh-cn/library/bb676556(v=exchg.80).aspx (2007)
https://technet.microsoft.com/zh-cn/library/bb123685%28v=exchg.141%29.aspx?f=255&MSPPError=-2147217396 (2010)
0
garryshapeAuthor Commented:
Here's what I did instead, which makes it easier:

get-mailbox -OrganizationalUnit "OU=IT,OU=Business,OU=Cafe,DC=cafenet,DC=edu" | Get-MailboxStatistics | Select DisplayName,@{label='SizeInMB';expression={$_.TotalItemSize.Value.ToMB()}  }

Open in new window


Then if I want to simply sum up the total of the SizeInMB column, I just add to the end of the line:

| Measure-Object 'SizeInMB' -Sum

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.