Saturday, May 28, 2016

Exchange 2010 (SP3) - Health check scripts (Cunningham)

There are a number of tools that allow us to validate our Exchange configuration and verify everything is functioning properly. In Exchange 2007 and 2010, we had the Exchange Best Practices Analyzer (ExBPA) which unfortunately is absent from Exchange 2013 and 2016. Exchange also offers a number of cmdlets that can be used to view the status of services, replication, mailbox databases, mail queues, Database Availabiity Groups and much more.

Here are some examples of cmdlets that I use rather frequently to verify the status of my Exchange environment:
  • Test-ServiceHealth (this verifies that all Exchange services are running)
  • Test-SystemHealth (this is essentially the command-line equivalent of the ExBPA).
  • Test-ReplicationHealth (this tests replication health between nodes of a Database Availability Group or "DAG").
  • Get-MailboxServer (in particular, this displays the "-databasecopyactivation" value)
  • Get-Mailboxdatabase | Get-MailboxdatabaseCopyStatus (This shows the status of our mailbox databases: mounted? dismounted?, etc.).
  • Get-DatabaseAvailabilityGroup -status | fl (this shows the status of the Database Availability Group).

When I was first learning these cmdlets, using them over and over again was a good method to memorize them. But entering cmdlet after cmdlet is not the most rapid and efficient method of quickly evaluating the health of your Exchange environment.

Fortunately, we can "script" much of the above and this approach has several avantages. Once configured, it requires less time and, with some scripts, we can even email the results in HTML format. This report can be sent to the Exchange administrators and, if desired, to managers who might be interested in the status of the messaging system.

Two of the most useful scripts I have recently evaluated were written by Exchange MVP Paul Cunningham:
  • Get-DAGHealth.ps1
  • Test-ExchangeServerHealth.ps1
You can read more about them on his (excellent) website

Here is the link to the page about the scripts:


Note: the DAG health check was incorporated into the Exchange Server Health check.

Running the scripts

So we download the script to a folder, extract it (if it is compressed as a zip file), open properties and unblock it.

I placed the two scripts here (for example):


We can run the scripts directly at the command line as follows:

(Click to enlarge)

For the first script, the output indicates that our Exchange environment is healthy. Apparently, the older DAG Health script does not produce output on the screen but it does expedite an HTML report to the email address that is configured.

Note: in the DAG Health script, we indicate the email address in an associated .xml file. For the Exchange Server Health script, we indicate the email address in the script itself.

Note: once again, although I tested both scripts, one would most likely just use the more general Exchange Server Health script since it covers everything concerning the DAG and more.

Scheduling the execution of the scripts (Task Scheduler)

The best way to use these scripts (in my opinion), is to schedule a task that will run them and indirectly send the HTML report to whoever should receive it (the Exchange administrators, for example, or perhaps certain managers).

I attained this objective by opening Task Scheduler and creating the new task as follows...

On the "General" tab, name the task and select the options shown below (with red dot):

On the "Triggers" tab, select "New":

Configure the task to run according to the schedule you desire, for example:

Likewise, on the "Actions" tab, select "New":

And configure the action:

For "Program/script" you can enter the full path to the powershell.exe executable file, but I discovered that this is not necessary (yes, the scripts are designed to run using PowerShell - we do not need to invoke the Exchange Management Shell or "EMS"). As for the arguments (that in my configuration designate the location of the script itself), I used the following terms:

 -NoLogo -NonInteractive -File "C:\Scripts\Get-DAGHealth.ps1" -Detailed -Sendemail

Or for the Exchange Server Health script (preferred):

-NoLogo -NonInteractive -File "C:\Scripts\Test-ExchangeServerHealth.ps1" -ReportMode -Sendemail

Other combinations may function just as well, In my case, my test user received the HTML report in is mailbox as expected.

No comments:

Post a Comment