2. Reporting Mailbox Folder Statistics
If you need to generate a report that
presents information about the folders in a specific mailbox, including the
number and size of items in the folder, the folder name and identity, and other
information, you can use the Get-MailboxFolderStatistics
EMS cmdlet.
You can identify the mailbox by specifying its Global Unique Identifier
(GUID), Active Directory object identity (ADObjectID), distinguished name (DN),
domain\account information, user principal name, LegacyExchangeDN, Simple Mail
Transport Protocol (SMTP) address, or alias. Optionally, you can use the
DomainController parameter to specify the fully qualified domain name of the
domain controller that retrieves data from Active Directory. For example, the
following command returns mailbox folder statistics for the Kim Akers
mailbox:
Get-MailboxFolderStatistics -Identity "Kim Akers"
Figure 8 shows some of the
output from this command.
Using the Get-MailboxFolderStatistics cmdlet without
filtering the information returns a large number of statistical values in a
format that is not well suited to a report. As with the
Get-MailboxStatistics cmdlet, you can use the
FL or FT PowerShell cmdlets to
refine the information. For example if you want to list the name of each folder
in the Kim Akers mailbox and the number of items in each folder, you would enter
the following command:
Get-MailboxFolderStatistics -Identity "Kim Akers" | FT Name,NumberOfItems
Figure 9 shows the output
from this command. Note that there were no items in any of the folders in this
mailbox when this command was entered. This can happen on a small test network,
but you are unlikely to obtain the same result on a production Exchange
organization.
Sometimes
you are interested in one or more specific folders in a mailbox. You can use the
FolderScope parameter to define the folders in which you are interested. The
FolderScope parameter specifies the scope of the search by folder type. Valid
parameter values include the following:
All
Calendar
Contacts
ConversationHistory
DeletedItems
Drafts
Inbox
JunkEmail
Journal
ManagedCustomFolder
Notes
Outbox
RecoverableItems
RssSubscriptions
SentItems
SyncIssues
Tasks
If the ManagedCustomFolder value is used, the command returns the output for
all managed custom folders. If the RecoverableItems value is entered, the
command returns the output for the Recoverable Items folder and the Deletions,
Purges, and Versions subfolders.
The following command returns the folder statistics for the Calendar folder in
the Don Hall mailbox:
Get-MailboxFolderStatistics -Identity "Don Hall" -FolderScope Calendar
Figure 10 shows the output
from this command.
You can decide
whether you want a command to return the dates of the oldest and newest items in
each folder by specifying the IncludeOldestAndNewestItems parameter. This can
take the value $true or $false.
As with commands based on the Get-MailboxStatistics
cmdlet, you can redirect the output from
Get-MailboxFolderStatistics commands into .txt or .csv
files for analysis by other software packages. You can use the
Sort-Object and Select-Object
PowerShell cmdlets to list folders in order of size or item count and to list,
say, the five largest or smallest folders.
If you need to analyze the folders on several mailboxes (for example, to list
the mailboxes with the largest DeletedItems folders), you can retrieve mailboxes
using the Get-Mailbox EMS cmdlet and then use the
ForEach-Object PowerShell cmdlet to obtain folder statistics for
each mailbox. You could, for example, use the Where-Object
PowerShell cmdlet to list all mailboxes that have items in their Outboxes.