$Mailboxes = Get-Mailbox -RecipientTypeDetails SharedMailbox
foreach ($Mailbox in $Mailboxes)
{
$Mailbox | Add-Member -MemberType “NoteProperty” -Name “MailboxSizeMB” -Value ((Get-MailboxStatistics $Mailbox).TotalItemSize.Value.ToMb())
$Mailbox | Add-Member -MemberType “NoteProperty” -Name “ItemCount” -Value ((Get-MailboxStatistics $Mailbox).ItemCount)
}
$Mailboxes | Sort-Object MailboxSizeMB -Desc | Select DisplayName,PrimarySMTPAddress,MailboxSizeMB,ItemCount,SamAccountName | Export-Csv -NoType “C:Mailboxessize.csv”