The other day, I was asked to provide an extract of all mailboxes in my exchange environment, along with attributes only available in other PS commands.
The below script provides the list (Get-Mailbox)along with a the sizes (Get-MailboxStatistics) and users’s associated dept(Get-User).
Hope it helps you.
Get-Mailbox -resultsize unlimited | sort-object | Select-Object DisplayName,PrimarySmtpAddress,@{n=”Size(KB)”;e = {$MBXstat = Get-MailboxStatistics $_.name; $MBXstat.totalItemsize}}, @{n=”ItemAcount”;e = {$MBXstat = Get-MailboxStatistics $_.name; $MBXstat.itemcount}},@{n=”Dept”;e={(get-aduser $_.name -properties department).department}} | export-csv mailboxout.csv