Exchange Powershell 2007/2010 Mailbox Audit

I'm trying to perform an audit of mailboxes in Exchange output to a Format Table with the following columns:
- Organizational Unit
- Display Name
- Database
- Mailbox Size
- Deleted Items Size
- Item Count

The Org Unit can only be pulled from Get-Mailbox and the rest of the data from Get-MailboxStatistics. My current script is here:
 
$OU = Get-Mailbox $_.OrganizationalUnit; 
Get-MailboxStatistics -Server <ServerName> | Sort-Object -property @{Expression="DatabaseName";Descending=$False},
@{Expression="TotalItemSize";Descending=$true} | ft OrganizationalUnit,DisplayName,DatabaseName,@{label="Mailbox Size(MB)";expression=
{$_.TotalItemSize.Value.ToMB()}},@{label="Del Items Size (MB)";expression={$_.TotalDeletedItemSize.Value.TOMB()}},ItemCount -GroupBy DatabaseName

Open in new window



It pulls all of the data from Get-MailboxStatistics, but not the Org Unit info from Get-Mailbox. This is probably the 17th iteration of this script and I can't get the Org Unit to be pulled into the table. Any help would be appreciated.

LVL 1
citsloginAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
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.

prashanthdCommented:
Try the following...
Get-MailboxStatistics -Server <ServerName> | Sort-Object -property @{Expression="DatabaseName";Descending=$False},@{Expression="TotalItemSize";Descending=$true} | ft @{label="OrganizationalUnit";expression={(get-mailbox $_).OrganizationalUnit}},DisplayName,DatabaseName,@{label="Mailbox Size(MB)";expression={$_.TotalItemSize.Value.ToMB()}},@{label="Del Items Size (MB)";expression={$_.TotalDeletedItemSize.Value.TOMB()}},ItemCount -GroupBy DatabaseName

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
citsloginAuthor Commented:
Awesome! It works beautifully, thanks! I had tried something along the lines of this previously, but the placement of the parenthesis was not something I was aware of, so kept failing out. Again, thanks so much!
0
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
Exchange

From novice to tech pro — start learning today.