As Exchange Administrators, we need to troubleshoot server issues from time to time when mail flow stops working or a change was implemented on the networking side and this has also caused an outage on your Exchange Server.

By defaults IP routes on Windows Server should allow communication to and from the server but sometimes persistent routes are setup and if they change then things stop working.

I put together a script to get the IP routes of multiple machines to check for consistency. I had a few servers that were not working the same and found that a route was added for testing but forgotten and this caused issues on the Exchange Server. This is the output of the script:

Quickly check your ip routes when troubleshooting networking issues on exchange 2019

Here is the second part as the output is long:

Quickly check your ip routes when troubleshooting networking issues on exchange 2019

SCRIPT

The script has one section that needs to be updated and this is the server list on line 2:

  • $servers – specify the server names, each separated by a comma

Here is the script for you to use:

# List of servers to check
$servers = @("Srv1", "Srv2", "Srv3")

foreach ($server in $servers) {
    try {
        # Invoke command on the remote server to get IP routes
        $routes = Invoke-Command -ComputerName $server -ScriptBlock {
            Route Print | Out-String
        } -ErrorAction Stop

        # Display the results
        Write-Host "IP Routes for $server"
        Write-Host $routes
        Write-Host ("-" * 75)  # Add a line of dashes as a separator
        Write-Host ("-" * 75)  # Add a line of dashes as a separator

    } catch {
        Write-Host "Error retrieving IP routes from $server. Error: $_"
    }
}

The script can be run from PowerShell ISE, PowerShell or the Exchange Management Shell.

Hope you find it helpful.

Discover more from Everything-PowerShell

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

Continue reading