As Exchange Administrators, we sometimes run into issues when mail stops flowing for example or Autodiscover is not working. Generally you would first look at the Event Logs but there is another section we need to also check. In Exchange, whether it is Exchange 2019, Exchange 2016 or Exchange 2013, the “Server Component State” will give you an indication if something is Inactive or a problem.

You can run the command from an Exchange Server but if you have multiple servers, this can be a task to login or want to view them all at the same time. I put together a script that loops through all the servers you define and shows each server in it’s own Grid so you can work through the information without having to scroll down a long list.

Here is a sample of 3x servers that show information:

Validate the server component state in exchange 2019


The script has one place where you need to modify information which is the following:

  • $servers – Enter the information of each server, separated by a comma

Here is the script:

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

# Define the list of Exchange servers
$servers = "Exch1", "Exch2", "Exch3"

# Create an array to store the results
$results = @()

# Iterate through each server
foreach ($server in $servers) {
    # Get the server component state
    $componentState = Get-ServerComponentState -Identity $server

   # Display the result on the screen for each server
    Write-Host "Server: $server"
    $componentState | Out-GridView -Title "Server Health - $server"

This script won’t run on Windows Server Core but you can use PowerShell ISE or PowerShell to run it, the Snapin is added to the beginning of the script if you need it.

Hope it helps.

Discover more from Everything-PowerShell

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

Continue reading