Wednesday, November 18, 2009

Quick Exchange 2007 Server Status

By:Rik Hoffelder
Over the past few years I have accumulated several time saver and management scripts for Exchange 2007 using the Exchange Management Shell. I thought I would begin sharing some of the more generic and useful scripts. This particular script collects data from various performance counters and runs several Exchange 2007’s Test- cmdlets. It then writes the data to a HTM file and opens with the results.

The script must be run from under Exchange Management Shell and is intended to run against one server. I’ll post another version that collects from multiple servers; however it has been my experience that if you have multiple Exchange servers, you probably already have a monitoring solution. This was written from my Mom & Pop customers would need a quick, yet free, monitoring method. It offers no alerting, just basic information.

To run, simply copy and paste the following into a text file named ExchangeReport.PS1 then launch it from Exchange Management Shell by running the following command:

C:\Scripts> ./ExchangeReport.PS1

After running the code the Report.HTM file will open and present several items in tables as shown below:


Code Sample:
$a = "<style>"
$a = $a + "BODY{background-color:white;}"
$a = $a + "TABLE{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}"
$a = $a + "TH{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:LightBlue}"
$a = $a + "TD{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:White}"
$a = $a + "</style>"

Get-ExchangeServer | Select-Object Name, AdminDisplayVersion, ServerRole, IsMemberofCluster | ConvertTo-HTML -head $a -body "<H2>Exchange Server Information</H2>" | Out-File Report.htm

Get-WmiObject Win32_service -errorAction silentlyContinue | Where-Object {$_.name -match "^msexchange."} |
select-object Name, Status ConvertTo-HTML -head $a -body "<H2>Exchange Services State</H2>" |
Out-File Report.htm -Append

Get-Queue | Select-Object Identity, MessageCount, Status, DeliveryType, NextHopDomain, LastError |
ConvertTo-HTML -head $a -body "<H2>Message Queues</H2>" |
Out-File Report.htm -Append

Get-WmiObject -query "select * from Win32_PerfFormattedData_MSExchangeTransportQueues_MSExchangeTransportQueues" |
select-object Name, ActiveRemoteDeliveryQueueLength, ActiveMailboxDeliveryQueueLength, SubmissionQueueLength, RetryMailboxDeliveryQueueLength |
ConvertTo-HTML -head $a -body "<H2>Message Queue Counters</H2>" |
Out-File Report.htm -Append

Get-WmiObject -errorAction silentlyContinue -query "Select * from Win32_PerfFormattedData_MSExchangeTransportSmtpSend_MSExchangeTransportSmtpSend" |
Select-Object MessageBytesSentPersec, MessageBytesSentTotal, MessagesSentPersec, MessagesSentTotal |
ConvertTo-HTML -head $a -body "<H2>SMTP Counters</H2>" |
Out-File Report.htm -Append

Get-WmiObject -errorAction silentlyContinue -query "Select * from Win32_PerfFormattedData_MSExchangeIS_MSExchangeIS" |
Select-Object ActiveUserCount, ActiveConnectionCount, ConnectionCount, RPCRequests, RPCPacketsPersec, RPCOperationsPersec, WriteBytesRPCClientsPersec, RPCAveragedLatency |
ConvertTo-HTML -head $a -body "<H2>Information Store Counters</H2>" |
Out-File Report.htm -Append

Get-WmiObject -errorAction silentlyContinue -query "Select * from Win32_PerfFormattedData_MSExchangeIS_MSExchangeISMailbox" |
Select-Object ClientLogons, ActiveClientLogons, MessageOpensPersec, FolderOpensPersec, AverageDeliveryTime, MessagesDeliveredPerSec, MessagesSentPersec, ReceiveQueueSize, MessagesQueuedForSubmission |
ConvertTo-HTML -head $a -body "<H2>Mailbox Store Counters</H2>" |
Out-File Report.htm -Append

Test-MAPIConnectivity | Select-Object Server, Database, Result, Latency, Error |
ConvertTo-HTML -head $a -body "<H2>MAPI Connectivity</H2>" |
Out-File Report.htm -Append

Test-OWAConnectivity | Select-Object ClientAccessServer, MailboxServer, URL, Scenario, Result, Latency, Error |
ConvertTo-HTML -head $a -body "<H2>OWA Connectivity</H2>" |
Out-File Report.htm -Append

Test-ActiveSyncConnectivity | Select-Object ClientAccessServer, MailboxServer, Scenario, Result, Latency, Error |
ConvertTo-HTML -head $a -body "<H2>ActiveSync Connectivity</H2>" |
Out-File Report.htm -Append

Test-MailFlow | Select-Object TestMailFlowResult, MessageLatencyTime, IsRemoteTest |
ConvertTo-HTML -head $a -body "<H2>Mail Flow</H2>" |
Out-File Report.htm -Append

Test-OutlookWebServices | Select-Object Id, Type, Message |
ConvertTo-HTML -head $a -body "<H2>Exchange Web Services</H2>" |
Out-File Report.htm -Append

Invoke-Expression Report.htm
#---End of Code Sample---


More information on Exchange

0 comments:

Post a Comment

Microsoft Virtualization, Citrix, XENServer, Storage, iscsi, Exchange, Virtual Desktops, XENDesktop, APPSense, Netscaler, Virtual Storage, VM, Unified Comminications, Cisco, Server Virtualization, Thin client, Server Based Computing, SBC, Application Delivery controllers, System Center, SCCM, SCVMM, SCOM, VMware, VSphere, Virtual Storage, Cloud Computing, Provisioning Server, Hypervisor, Client Hypervisor.