In my previous blog post, we looked at the Exchange Server Server Component State and how to validate each item. We will continue with the health checking and look at the Server Health state in Exchange Server, this can be Exchange 2019 or Exchange 2016.

In this blog, I wanted to show you how you can filter the “HealthSet” by only showing the “HubTransport” section as this command shows a lot of information. I put together a script that checks the ServerHealth for multiple Exchange Servers and shows each one in its own Grid because the information displays much clearer and is less cluttered.

Below is a sample output of the three (3) Exchange servers this script ran against:

Check the server health in exchange 2019 with powershell

SCRIPT

The script only has one section that needs to be updated which is as follows:

  • $ServerNames – Specify the server names, each separated by a comma (,)

Here is the script that you can use:

# Import the Exchange module
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.SnapIn

# Define an array of server names
$serverNames = @("exch1", "exch2", "exch3")

# Iterate through each server
foreach ($serverName in $serverNames) {
    # Get server health for the current server
    $results = Get-ServerHealth -HealthSet "HubTransport" -Identity $serverName

    # Display the results in a grid for each server
    $results | Out-GridView -Title "Server Health - $serverName"
}

The script will not work on Windows Server Core because it cannot display Grid layouts but you can use it from PowerShell or PowerShell ISE.

Hope it helps.

    wpChatIcon

    Discover more from Everything-PowerShell

    Subscribe now to keep reading and get access to the full archive.

    Continue reading