Logo
Windows XP
Windows Vista
Windows 7
Windows Azure
Windows Server
Windows Phone
EPL Standings
 
 
Windows Server

Using Windows PowerShell in an Exchange Server 2010 Environment : Using EMS to Do Reporting

3/24/2011 9:09:25 PM
EMS has built-in reporting features that use a variety of outputs. For example, the following cmdlet verifies server functionality by logging on to the specified user’s mailbox and reporting the latency (see Figure 1):
Test-MapiConnectivity amy@companyabc.com

Figure 1. Output generated by EMS MapiConnectivity Test.

Output is normally sent to the display, but it can also be sent to files using redirection. EMS has special cmdlets that also produce comma-separated values (CSV), Extensible Markup Language (XML), and HTML output. These types of output provide the flexibility that administrators need to manipulate the data using familiar tools, such as Microsoft Excel.

Generating User Distribution Reports

Reports that list user mailbox distribution across all mailbox stores can be helpful to know if the user load is balanced in the organization. The following .ps1 example shows how to produce a report listing the total number of mailbox stores, the number of mailboxes in each store, and the total number of mailboxes.

This .ps1 script contains comments, variables, and error trapping. Comments begin with the “#” symbol and are useful for administrators to understand what the script or cmdlet is doing and are ignored by EMS/PowerShell. Variables always start with the $ symbol and are used to assign values or collections. Error trapping handles exceptions or errors that can occur in the script so that the script continues to run:

#Get all mailbox stores in the organization and assign them to the $MailboxDatabases array variable
$MailboxDatabases = get-mailboxdatabase
write-host "There are" $MailboxDatabases.Count "Mailbox Stores in the organization."
write-host ("-"*70)

#Get each database and assign it to the $Database array variable
ForEach ($Database in $MailboxDatabases) {
#Derive the Mailbox server name from the database
$MailboxServer = $Database.server.name
#Derive the database name from the database
$DatabaseName = $Database.name
#Assign the full database name to the $FullDatabaseName variable
$FullDatabaseName = "$MailboxServer" + "\" + "$DatabaseName"
#Count the number of databases on the server
$count=0
get-mailboxdatabase –server $MailboxServer | ForEach-Object {$count++}
#Get the mailboxes for this database
If ($count –gt 1) {
$mailbox = get-mailbox -database $FullDatabaseName
}
Else {
$mailbox = get-mailbox -database $DatabaseName
}
write-host "There are" $mailbox.Count.toString("#,#") "mailboxes in" $FullDatabaseName

#The trap statement traps the NullException error which occurs when a database has no mailboxes
trap{
write-host "There are no mailboxes in" $FullDatabaseName;
continue
}
}

write-host ("-"*70)
#Get all mailboxes in the organization
$mailboxes = get-Mailbox
write-host "The total number of mailboxes in the organization is" $mailboxes.count.tostring("#,#")


Working with Event Logs

Exchange Server administrators often work with Windows event logs to troubleshoot issues. Because EMS runs in the PowerShell environment, the administrator can take advantage of PowerShell’s Get-Eventlog cmdlet to work with event logs.

This example displays all events in the Application Event Log in which the source begins with the word “Exchange.” The output is exported to a CSV file for easy manipulation in Microsoft Excel:

get-eventlog Application | where {$_.Source -ilike "Exchange*"} | export-csv c:\events.csv			  

Other -----------------
- Exchange Server 2010 : Using EMS to Do Administrative Mailbox Tasks (part 2)
- Exchange Server 2010 : Using EMS to Do Administrative Mailbox Tasks (part 1)
- SharePoint 2010 PerformancePoint Services : Excel Services Data Source
- SharePoint 2010 PerformancePoint Services : PowerPivot Data Sources
- Windows Server 2003 : Monitoring Network Protocol Security (part 7)
- Windows Server 2003 : Monitoring Network Protocol Security (part 6) - Use Netsh to Manage IPSec
- Windows Server 2003 : Monitoring Network Protocol Security (part 5) - Create a Negotiation Policy
- Windows Server 2003 : Monitoring Network Protocol Security (part 4) - Use the IP Security Management Snap-In to Create a Blocking Policy
- Windows Server 2003 : Monitoring Network Protocol Security (part 3) - Understanding Kerberos
- Windows Server 2003 : Monitoring Network Protocol Security (part 2) - Negotiation Process
- Windows Server 2003 : Monitoring Network Protocol Security (part 1) - Understanding IPSec & Negotiation Configuration
- SharePoint 2010 : Getting to Know the Excel Services Service Application
- Using Windows PowerShell in an Exchange Server 2010 Environment : Managing Cmdlets
- Using Windows PowerShell in an Exchange Server 2010 Environment : Creating Your Own Scripts
- Windows Server 2008 R2 : Installing Windows Deployment Services (part 3)
- Windows Server 2008 R2 : Installing Windows Deployment Services (part 2)
- Windows Server 2008 R2 : Installing Windows Deployment Services (part 1) - Configuring the WDS Server
- Windows Server 2008 R2 Windows Deployment Services
- Windows Server 2008 R2 Administration Tools for Desktops : Operating System Deployment Options
- Windows Server 2008 R2 Administration Tools for Desktops : Managing Desktops and Servers
 
 
Most view of day
- SQL Server 2012 : Running SQL Server in A Virtual Environment - EXTENDED FEATURES OF VIRTUALIZATION
- Microsoft PowerPoint 2010 : Animating Slide Content (part 5) - Animating Parts of a Chart, Animation Tips
- System Center Configuration Manager 2007 : Operating System Deployment - Task Sequences (part 1) - Variables
- Windows Phone 7 : 3D Game Development (part 1) - 3D Game Concepts
- Client Access to Exchange Server 2007 : Using Outlook 2007 Collaboratively (part 1)
- Maintaining Windows Home Server 2011 : Defragmenting the System Drive, Reviewing Event Viewer Logs, Setting Up a Maintenance Schedule
- Microsoft Visio 2010 : Linking External Data to Shapes (part 3) - Using the Database Wizard - Setting Up the Excel File as a Data Source
Top 10
- Microsoft OneNote 2010 : Using the Research and Translate Tools (part 3) - Translating Text with the Mini Translator
- Microsoft OneNote 2010 : Using the Research and Translate Tools (part 2) - Translating a Word or Phrase with the Research Pane
- Microsoft OneNote 2010 : Using the Research and Translate Tools (part 1) - Setting Options for the Research Task Pane, Searching with the Research Task Pane
- Microsoft OneNote 2010 : Doing Research with Linked Notes (part 2) - Ending a Linked Notes Session, Viewing Linked Notes
- Microsoft OneNote 2010 : Doing Research with Linked Notes (part 1) - Beginning a Linked Notes Session
- Microsoft OneNote 2010 : Doing Research with Side Notes (part 3) - Moving Side Notes to Your Existing Notes
- Microsoft OneNote 2010 : Doing Research with Side Notes (part 2) - Reviewing Side Notes
- Microsoft OneNote 2010 : Doing Research with Side Notes (part 1) - Creating Side Notes
- Games and Windows 7 : Installing and Playing Third-Party Games
- Games and Windows 7 : Using the Games Explorer (part 4) - Managing Your Game Controllers and Other Game-Related Hardware
 
 
Windows XP
Windows Vista
Windows 7
Windows Azure
Windows Server
Windows Phone
2015 Camaro