Book Image

Microsoft Exchange Server PowerShell Cookbook

Book Image

Microsoft Exchange Server PowerShell Cookbook

Overview of this book

Table of Contents (21 chapters)
Microsoft Exchange Server PowerShell Cookbook Third Edition
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Determining the average mailbox size per database


PowerShell is very flexible and gives you the ability to generate very detailed reports. When generating mailbox database statistics, we can utilize the data returned from multiple cmdlets provided by the Exchange Management Shell. This recipe will show you an example of this, and you will learn how to calculate the average mailbox size per database using PowerShell.

How to do it...

To determine the average mailbox size of a given database, use the following commands:

Get-MailboxStatistics -Database DB1 | 
ForEach-Object {$_.TotalItemSize.value.ToMB()} | 
Measure-Object -Average | 
Select-Object –ExpandProperty Average

How it works...

Calculating an average is as simple as performing some basic math, but PowerShell gives us the ability to do this quickly with the Measure-Object cmdlet. The example uses the Get-MailboxStatistics cmdlet to retrieve all the mailboxes in the DB1 database. We then loop through each one, retrieving only the TotalItemSize...