How to create report of user mailbox size for Exchange in Powershell.(DisplayName, PrimarySmtpAddress, TotallItemSize).

This is one of my favorite Powershell scripts. Easy way to show how big are Exchange mailboxes and make your boss happy 🙂

This is the result:

Exchange Users, Mialbox Report

Copy and past 🙂

$Report=@()
$mailbox=Get-mailbox –resultsize unlimited
$mailbox| foreach-object{
$DisplayName=$_.DisplayName
$SmtpAddress=$_.PrimarySmtpAddress
$TotalItemSize=(get-mailboxstatistics –identity $DisplayName ).TotalITemSize
$obj=new-object System.Object
$obj|add-member -membertype NoteProperty -name "DisplayName" -value $DisplayName
$obj|add-member -membertype NoteProperty -name "PrimarySmtpAddress" -value $SmtpAddress
$obj|add-member -membertype NoteProperty -name "TotalItemSize" -value $TotalItemSize
$Report+=$obj
}
$path_s=[Environment]::GetFolderPath("Desktop")
$Report|Sort "TotalItemSize" -Descending | export-csv $path_s\report.csv -notype