Origin:
https://gallery.technet.microsoft.com/office/Mailbox-Size-Report-for-ed9435e2
Write-host " Mailbox Size Report ---------------------------- 1.Display in Exchange Management Shell 2.Export to CSV File 3.Enter the Mailbox Name with Wild Card (Export) 4.Enter the Mailbox Name with Wild Card (Display)"-ForeGround "Cyan" #---------------- # Script #---------------- Write-Host " " $number = Read-Host "Choose The Task" $output = @() switch ($number) { 1 { $AllMailbox = Get-mailbox -resultsize unlimited Foreach($Mbx in $AllMailbox) { $Stats = Get-mailboxStatistics $Mbx.identity.distinguishedname $userObj = New-Object PSObject $userObj | Add-Member NoteProperty -Name "Display Name" -Value $mbx.displayname $userObj | Add-Member NoteProperty -Name "Primary SMTP address" -Value $mbx.PrimarySmtpAddress $userObj | Add-Member NoteProperty -Name "TotalItemSize" -Value $Stats.TotalItemSize $userObj | Add-Member NoteProperty -Name "ItemCount" -Value $Stats.ItemCount Write-Output $Userobj } ;Break} 2 { $CSVfile = Read-Host "Enter the Path of CSV file (Eg. C:\Report.csv)" $AllMailbox = Get-mailbox -resultsize unlimited Foreach($Mbx in $AllMailbox) { $Stats = Get-mailboxStatistics $Mbx.identity.distinguishedname $userObj = New-Object PSObject $userObj | Add-Member NoteProperty -Name "Display Name" -Value $mbx.displayname $userObj | Add-Member NoteProperty -Name "Alias" -Value $Mbx.Alias $userObj | Add-Member NoteProperty -Name "RecipientType" -Value $Mbx.RecipientType $userObj | Add-Member NoteProperty -Name "Recipient OU" -Value $Mbx.OrganizationalUnit $userObj | Add-Member NoteProperty -Name "Primary SMTP address" -Value $Mbx.PrimarySmtpAddress $userObj | Add-Member NoteProperty -Name "Database" -Value $Stats.Database $userObj | Add-Member NoteProperty -Name "ServerName" -Value $Stats.ServerName $userObj | Add-Member NoteProperty -Name "TotalItemSize" -Value $Stats.TotalItemSize $userObj | Add-Member NoteProperty -Name "ItemCount" -Value $Stats.ItemCount $userObj | Add-Member NoteProperty -Name "DeletedItemCount" -Value $Stats.DeletedItemCount $userObj | Add-Member NoteProperty -Name "TotalDeletedItemSize" -Value $Stats.TotalDeletedItemSize $userObj | Add-Member NoteProperty -Name "DatabaseProhibitSendReceiveQuota" -Value $Stats.DatabaseProhibitSendReceiveQuota $userObj | Add-Member NoteProperty -Name "LastLogonTime" -Value $Stats.LastLogonTime $output += $UserObj } $output | Export-csv -Path $CSVfile -NoTypeInformation ;Break} 3 { $CSVfile = Read-Host "Enter the Path of CSV file (Eg. C:\DG.csv)" $MailboxName = Read-Host "Enter the Mailbox name or Range (Eg. Mailboxname , Mi*,*Mik)" $AllMailbox = Get-mailbox $MailboxName -resultsize unlimited Foreach($Mbx in $AllMailbox) { $Stats = Get-mailboxStatistics $Mbx.identity.distinguishedname $userObj = New-Object PSObject $userObj | Add-Member NoteProperty -Name "Display Name" -Value $mbx.displayname $userObj | Add-Member NoteProperty -Name "Alias" -Value $Mbx.Alias $userObj | Add-Member NoteProperty -Name "RecipientType" -Value $Mbx.RecipientType $userObj | Add-Member NoteProperty -Name "Recipient OU" -Value $Mbx.OrganizationalUnit $userObj | Add-Member NoteProperty -Name "Primary SMTP address" -Value $Mbx.PrimarySmtpAddress $userObj | Add-Member NoteProperty -Name "Database" -Value $Stats.Database $userObj | Add-Member NoteProperty -Name "ServerName" -Value $Stats.ServerName $userObj | Add-Member NoteProperty -Name "TotalItemSize" -Value $Stats.TotalItemSize $userObj | Add-Member NoteProperty -Name "ItemCount" -Value $Stats.ItemCount $userObj | Add-Member NoteProperty -Name "DeletedItemCount" -Value $Stats.DeletedItemCount $userObj | Add-Member NoteProperty -Name "TotalDeletedItemSize" -Value $Stats.TotalDeletedItemSize $userObj | Add-Member NoteProperty -Name "DatabaseProhibitSendReceiveQuota" -Value $Stats.DatabaseProhibitSendReceiveQuota $userObj | Add-Member NoteProperty -Name "LastLogonTime" -Value $Stats.LastLogonTime $output += $UserObj } $output | Export-csv -Path $CSVfile -NoTypeInformation ;Break} 4 { $MailboxName = Read-Host "Enter the Mailbox name or Range (Eg. Mailboxname , Mi*,*Mik)" $AllMailbox = Get-mailbox $MailboxName -resultsize unlimited Foreach($Mbx in $AllMailbox) { $Stats = Get-mailboxStatistics $Mbx.identity.distinguishedname $userObj = New-Object PSObject $userObj | Add-Member NoteProperty -Name "Display Name" -Value $mbx.displayname $userObj | Add-Member NoteProperty -Name "Primary SMTP address" -Value $mbx.PrimarySmtpAddress $userObj | Add-Member NoteProperty -Name "TotalItemSize" -Value $Stats.TotalItemSize $userObj | Add-Member NoteProperty -Name "ItemCount" -Value $Stats.ItemCount Write-Output $Userobj } ;Break} Default {Write-Host "No matches found , Enter Options 1 or 2" -ForeGround "red"} }
Save this file as a ps1 file, then in the exchange command console, issue the file.