Share via


Show Mailbox Size for Users in a Database

Introduction

This PowerShell code will show you have to view the mailbox size for users in a database.

Prerequisites List

  • Admin Access to Exchange to be able to manage mailboxes.

Script Info

This script finds all the users mailboxes and displays the Name of the User, the server name and the size in Megabytes (MB).

You can change the view to Gigabytes (GB) instead of Megabytes (MB) by changing the following values in the script:

  • MailboxSizeMB -> MailboxSizeGB
  • Value.ToMB -> Value.ToGB

Powershell Script:

$a = "<style>"
 $a = $a + "BODY{background-color:00557F;}"
 $a = $a + "TABLE{border-width: 1px;border-style: solid;border-color: 006699;border-collapse: collapse;}"
 $a = $a + "TH{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:thistle}"
 $a = $a + "TD{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:white}"
 $a = $a + "</style>"
 
 $Mailboxes = Get-Mailbox -ResultSize Unlimited 
 
 foreach ($Mailbox in $Mailboxes) 
 {
$Mailbox | Add-Member -MemberType "NoteProperty"  -Name "MailboxSizeMB"  -Value ((Get-MailboxStatistics $Mailbox).TotalItemSize.Value.ToMB())
 }
 $Mailboxes | Sort-Object MailboxSizeMB -Desc | Select DisplayName, ServerName, MailboxSizeMB | ConvertTo-Html -Head $a | Out-File c:\MailboxList.htm