PowerShell to Generate Exchange Mailbox Usage Report

You can run the PowerShell Scirpt below on Exchange 2010 SP3 server to export Mailbox Usage Report to CSV File

#Connect to Exchange - PowerShell ISE - Exchange 2010 
. 'C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1'
Connect-ExchangeServer -auto

$Results = @() #Declare Array for all results 
$Mailboxes = Get-Mailbox -ResultSize Unlimited -RecipientType UserMailbox 
#$Mailboxes = Get-Mailbox -identity group2

foreach($Mailbox in $Mailboxes)
{
    $UPN = $Mailbox.UserPrincipalName
    $MailboxStat = Get-MailboxStatistics $UPN 

    $Properties = @{
      Name = $Mailbox.DisplayName
      UPN = $UPN
      Database = $mailboxStat.Database
      LastLogon = $MailboxStat.lastlogontime
      TotalItems = $MailboxStat.ItemCount
      TotalItemSize = $MailboxStat.TotalItemSize.Value.ToMB()
      DeletedItems = $MailboxStat.TotalDeletedItemSize.Value.ToMB()
      }

    $Results += New-Object psobject -Property $properties

}

 $Results | Export-Csv C:\temp\mailboxreport-20181707.csv -NoTypeInformation

You will get the CSV Report as below

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top