Book Image

Microsoft Exchange 2010 PowerShell Cookbook

Book Image

Microsoft Exchange 2010 PowerShell Cookbook

Overview of this book

Table of Contents (22 chapters)
Microsoft Exchange 2010 PowerShell Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Reporting on the mailbox size


Using cmdlets from both the Exchange Management Shell and Windows PowerShell gives us the ability to generate detailed reports. In this recipe, we will use these cmdlets to report on all of the mailboxes within an organization and their total size.

How to do it...

  1. Use the following one-liner to generate a report of each mailbox in the organization and the total mailbox size:

    Get-MailboxDatabase | Get-MailboxStatistics | 
      ?{!$_.DisconnectDate} | 
        Select-Object DisplayName,TotalItemSize
  2. Pipe the command even further to export the report to a CSV file that can be opened and formatted in Excel:

    Get-MailboxDatabase | Get-MailboxStatistics | 
      ?{!$_.DisconnectDate} | 
        Select-Object DisplayName,TotalItemSize | 
          Export-CSV c:\mbreport.csv -NoType

How it works...

In both commands, we're using the Get-MailboxDatabase cmdlet to pipe each database in the organization to the Get-MailboxStatistics cmdlet. Notice that in the next stage of the pipeline we are filtering...