Logo
programming4us
programming4us
programming4us
programming4us
Home
programming4us
XP
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server
programming4us
Windows Phone
 
Windows Server

Exchange Server 2010 : Generating Reports (part 1) - Generating Mailbox Statistics Reports

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
5/20/2011 11:40:35 AM

1. Generating Mailbox Statistics Reports

Although it is possible to write scripts that use Windows Management Instrumentation or Messaging Application Programming Interface (MAPI) to generate mailbox statistics reports, and such scripts can still be found on the Internet, Exchange Server 2010 (and Exchange Server 2007) provides a less complex method of achieving the same results. EMS cmdlets provide direct access to the statistics you require, and PowerShell cmdlets offer you the facility to generate formatted reports from the command line or to export information in text or CSV files that can be read and manipulated by other software packages, such as Microsoft Office Excel.

If you run the Get-MailboxStatistics EMS cmdlet against a Mailbox server or against a mailbox database or an individual mailbox on the Mailbox server on which the command is entered, it lists the display name of the mailbox, the number of items in the mailbox, the mailbox storage limit status, and the last logon time. If you want to find out what other statistics are available for a mailbox, you can pipe the output into the PowerShell FL cmdlet. Doing this for every mailbox on a server would typically provide too much information, so you would typically specify a mailbox. For example, the following command lists all the statistics for the Don Hall mailbox:

Get-MailboxStatistics -Identity "Don Hall" | FL

Figure 1 shows the output from this command.

Figure 1. Statistics available for a mailbox


Even for a single mailbox you obtain a significant amount of information, and you might find it convenient to redirect the output of Get-MailboxStatistics commands to a text file. The following example places the statistics for the Don Hall Mailbox in the file donstats.txt in the folder C:\MailboxStats on the server on which the command is run:

Get-MailboxStatistics -Identity "Don Hall" | FL > C:\MailboxStats\donstats.txt


Note that if the file donstats.txt did not already exist, this command would create it. However, the folder C:\MailboxStats must already exist; otherwise, the command returns an error.

Running the Get-MailboxStatistics cmdlet against a mailbox and piping the result into the FL cmdlet helps identify the names of the mailbox statistics that the cmdlet returns, for example, ItemCount, LastLogonTime, LastLogoffTime, TotalItemSize, ServerName, DatabaseName, and so on. If you want to return the values of only the statistics you are interested in, you can use these names (known as attribute identifiers) with the FL cmdlet. For example, the following command returns the display name, total item size, and item count for the Don Hall mailbox:

Get-MailboxStatistics -Identity "Don Hall" | FL DisplayName,TotalItemSize,ItemCount

1.1. Displaying Data in Tables

Displaying the statistics for a single mailbox in list format is usually satisfactory, but if you are displaying several statistics for several mailboxes, the result is typically clearer in tabular format. In this case, you pipe the output of the Get-MailboxStatistics cmdlet into the FT PowerShell cmdlet. The following example lists the display name, total item size, and item count for all the mailboxes in the mailbox database named Mailbox Database 1363123687:

Get-MailboxStatistics -Database "Mailbox Database 1363123687" | FT DisplayName,
TotalItemSize,ItemCount


Figure 2 shows the output from this command.

Figure 2. Mailbox statistics in tabular form


A table on an EMS screen is, however, not the best way to display a report. You can convert the output of the Get-MailboxStatistics cmdlet to CSV format by using the Export-CSV PowerShell cmdlet and storing the output in a CSV file. You can then display or manipulate the file by using software that reads CSV files, such as Microsoft Excel. The following command creates the file MailboxStats.csv in the C:\MailboxStats folder:

Get-MailboxStatistics -Database "Mailbox Database 1363123687" | Export-CSV
C:\MailboxStats\MailboxStats.csv

This command captures all the statistics for all the mailboxes in the Mailbox Database 1363123687 database. Typically, you would use reporting software to manipulate the CSV file and display the information you want to see. Data is saved in ASCII format by default. If you want to save the data in, for example, Unicode format, you can use the Encoding parameter followed by the desired format, such as follows:

Get-MailboxStatistics -Database "Mailbox Database 1363123687" | Export-CSV
C:\MailboxStats\MailboxStats.csv -Encoding unicode

By default, the first line of any CSV file you create with Export-CSV lists the .NET object type in its first line, for example, #TYPE Microsoft.Exchange.Data.Mapi.MailboxStatistics. If you do not want to list this information, you can specify the Notype parameter, such as follows:

Get-MailboxStatistics -Database "Mailbox Database 1363123687" | Export-CSV
C:\MailboxStats\MailboxStats.csv -Notype


1.2. Listing Results by Statistic Values

You can use the values of mailbox statistics to generate reports that list mailboxes that meet specific conditions. For example, if you wanted a report that gave details of all disconnected mailboxes on the Mailbox server VAN-EX1, you could use the PowerShell Where clause, such as follows:

Get-MailboxStatistics -Server VAN-EX1 | Where {$_.DisconnectDate -ne $null}| FT


Figure 3 shows the output of this command. (Note that the Don Hall mailbox was disconnected using the Disable-Mailbox cmdlet before the command was entered.)

Figure 3. Listing disconnected mailboxes


As before, you can place the output of the previous command into a CSV file, such as follows

Get-MailboxStatistics -Server VAN-EX1 | Where {$_.DisconnectDate -ne $null} | Export-Csv
C:\ \MailboxStats\DisconnectedMailboxes.csv -Notype


The Where clause can also be used to list all mailboxes that are greater than or equal to a defined size or hold a defined number of messages or more. You could, for example, list all mailboxes on a Mailbox server that have a size of 1 GB or greater. However, on your isolated test network, it would be most unlikely that the size of any mailbox would exceed 1 GB or even 1 MB. Therefore, the following command lists all the mailboxes on the Mailbox server VAN-EX1 with a total item size greater than or equal to 1 KB:

Get-MailboxStatistics -Server VAN-EX1 | Where ($_.TotalItemSize -ge 1KB) | FT
DisplayName,TotalItemSize


Figure 4 shows the output from this command.

Similarly, the item counts in the mailboxes on your test network will be much lower than they would be on a production Exchange organization. The following command lists all the mailboxes on the Mailbox server VAN-EX1 with an item count greater than or equal to 2:

Get-MailboxStatistics -Server VAN-EX1 | Where ($_.ItemCount -ge 2) | FT
DisplayName,ItemCount

Figure 4. Mailboxes with a total item size greater than or equal to a specified value


Figure 5 shows the output of this command.

Figure 5. Mailboxes with an item count greater than or equal to a specified value


As before, you can redirect this information to a CSV file that you can use to generate a report.


1.3. Listing Mailboxes in a Defined Order

Sometimes you do not want to know the absolute item size of mailboxes but instead want to list them in a specified order. You can use the PowerShell Sort-Object cmdlet, to sort mailboxes in the order defined by a mailbox statistic, such as TotalItemSize or ItemCount. By default, the list will be in ascending order, but you can use the Descending parameter to order the list so that the largest values are first. For example, to list the display name, total item size, and total item count of the mailboxes on the Mailbox server VAN-EX1 in descending order of total item size, you would enter the following command:

Get-MailboxStatistics -Server VAN-EX1 | Sort-Object TotalItemSize -Descending |
FT DisplayName,TotalItemSize,ItemCount


Figure 6 shows the output from this command. As before, you have the option of capturing this output in a CSV file.

Figure 6. Mailboxes on the Mailbox server VAN-EX1 in descending order of total item size


If you do not want to list all the mailboxes in a mailbox database or Mailbox server (typically this would be too much information) but instead want to list, for example, the five largest mailboxes in terms of item count, you can use the PowerShell Select-Object cmdlet. For example, the following command lists the top five mailboxes on the Mailbox server VAN-EX1 in descending order of item count:

Get-MailboxStatistics -Server VAN-EX1 | Sort-Object ItemCount -Descending | Select-
Object -First 5 | FT DisplayName,ItemCount


Figure 7 shows the output from this command.

Figure 7. Sorting the first five results in order of item count


Other -----------------
- SharePoint 2010 PerformancePoint Services : Using Windows PowerShell and Cmdlets (part 2) - Cmdlet Samples
- SharePoint 2010 PerformancePoint Services : Using Windows PowerShell and Cmdlets (part 1) - Cmdlets Available Out of the Box
- BizTalk 2010 Recipes : Administration and Operations - Restarting the BizTalk Host Instance(s)
- BizTalk 2010 Recipes : Administration and Operations - Tracking Messages
- BizTalk 2010 Recipes : Administration and Operations - Debugging Orchestrations
- Monitoring Exchange Server 2010 : Debugging Network Connectivity (part 4) - Using Exchange Server ActiveSync
- Monitoring Exchange Server 2010 : Debugging Network Connectivity (part 3)
- Monitoring Exchange Server 2010 : Debugging Network Connectivity (part 2)
- Monitoring Exchange Server 2010 : Debugging Network Connectivity (part 1) - Using Telnet to Test SMTP Communication
- Backing Up Windows Server 2008 R2 Role Services (part 3)
 
 
Top 10
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
 
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server