Book Image

Microsoft Exchange Server Powershell Cookbook (Update)

Book Image

Microsoft Exchange Server Powershell Cookbook (Update)

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

Finding the total number of mailboxes in a database


You can retrieve all kinds of information about a mailbox database using the Exchange Management Shell cmdlets. Surprisingly, the total number of mailboxes in a given mailbox database is not one of those pieces of information. We need to retrieve this data manually. Luckily, PowerShell makes this easy, as you will see in this recipe.

How to do it...

Let's see how to find the total number of mailboxes in a database using the following steps:

  1. There are two ways that you can retrieve the total number of mailboxes in a database. First, we can use the Count property of a collection of mailboxes:

    @(Get-Mailbox -Database DB1).count
    
  2. Another way to retrieve this information is to use the Measure-Object cmdlet using the same collection from the preceding example:

    Get-Mailbox -Database DB1 | Measure-Object
    

How it works...

In both the steps, we use the Get-Mailbox cmdlet and specify the -Database parameter, which will retrieve all of the mailboxes in that...