This is a quick tactical script to help Exchange administrators when resetting Exchange Monitoring mailboxes. Exchange 2013 introduced managed availability which is responsible for evaluating the health of Exchange 2013 and 2016 Exchange servers. Yes it does also probe downlevel servers, but let’s not get bogged down in that in this post. In order to do the synthetic user tests, mail and tests flow between the endpoints. Special mailboxes called monitoring mailboxes are used for this purpose. They are sometimes also called health mailboxes. The below is a lab Exchange 2013 CU12 system. It currently has a single mailbox database, and there are 13 Monitoring Mailboxes reported.
In normal runstate, the administrator does not have to manage these health mailboxes. Normally Exchange will do this via the Health Manager service which runs locally on each Exchange 2013 or 2016 server. Sometimes though there may be an issue where you wish to clear and reset all the health mailboxes for an organisation.
Bhalchandra outlines the process to reset all health mailboxes:
Make sure “Monitoring Mailboxes” container is present in Active Directory users & computers
Stop the “Microsoft Exchange Server Health Manager” service on all Exchange Server 2013 servers
In Exchange Management Shell use following command to disable existing health mailboxes Get-Mailbox -Monitoring | Disable-Mailbox
In Active Directory users & computers, right click on domain and search for “HealthMailbox”
Delete the health mailbox user accounts
Wait for AD replication or force AD replication
Start the “Microsoft Exchange Server Health Manager” on all Exchange Server 2013 servers
The above bullets do not contain all the details, please see the referenced post for the entire process.
Since we can remove all monitoring mailboxes with quick and simple commands, the act of having to stop the Exchange Health Manager service on all Exchange servers is time consuming. To save time, stopping and starting the Health Manager service on all Exchange 2013 servers was automated and scripted.
Note that only the act of stopping the Health Manager service was automated. This was for a couple of reasons:
This is not considered normal maintenance and thus did not want to automate end to end, else someone may be tempted to schedule this as a task every Sunday morning
One script does not have the knowledge to deal with every environment. Thus you will still need to do the AD work etc, and confirm the results in your environment.
YOU must still perform the other steps. This script does not do everything. I’m working on the Make-Coffee module, but it is nowhere near complete.
Running The Script
Script requires a command line parameter. You must specify the action to take. Accepted actions are:
Stop -- will stop the Microsoft Exchange Health Manager service (MSExchangeHM) on the servers returned in the collection
Start -- will stop the Microsoft Exchange Health Manager service (MSExchangeHM) on the servers returned in the collection
Check -- will display the status of the Microsoft Exchange Health Manager service (MSExchangeHM) on the servers returned in the collection
CmdletBinding was added to check for the command line parameter being added, and to check the values entered. It also allows you to tab complete them, as an added bonus. Sweet!
The below are examples of what you should seen when running the script. First the services are stopped on all Exchange 2013 servers.
We then use the Check parameter to validate that all services are indeed stopped.
After you have manually done the addition steps, remember that *you* must do that manually, we start the services.
In reality, we would also perform another check at this point to make sure all are reported as running.
The script can be downloaded from the TechNet script gallery: