How to Troubleshoot Windows Server Network connectivity issues via PowerShell

We all have been there, we want to set up a new application or agent which needs network access and needs to reach an endpoint using a specific port, but it simply doesn't work. So as a server admin, we need to have a tool to network connectivity issues on to figure out is DNS working, is the remote endpoint even reachable, is the port open, and many other things. Luckily, comes with PowerShell and has build-in cmdlets to help with that. My favorite PowerShell cmdlet to network connectivity issues is Test-NetConnection.

The Test-NetConnection cmdlet displays diagnostic information for a connection. It supports ping test, test, route tracing, and route selection diagnostics. Depending on the input parameters, the output can include the DNS lookup results, a list of IP interfaces, IPsec rules, route/source address selection results, and/or confirmation of connection establishment.

You can do simple things, like just testing ping connectivity:

Test-NetConnection itopstalk.com

But you can also get some more detailed information on the connectivity:

Test-NetConnection itopstalk.com -InformationLevel “Detailed”

PowerShell Test-NetConnection cmdletPowerShell Test-NetConnection cmdlet

However, there is more! One of the commands I need the most, especially when working with web services, is to test a specific port.

Test-NetConnection itopstalk.com -Port 443 -InformationLevel “Detailed”

Test TCP Port using PowerShellTest Port using PowerShell

You can also perform route diagnostics to connect to a remote host.

Test-NetConnection -ComputerName itopstalk.com -DiagnoseRouting -InformationLevel Detailed

PowerShell Diagnose RoutingPowerShell Diagnose Routing

If you want to learn more about the Test-NetConnection cmdlet to network connectivity issues, check out Microsoft Docs.

Test-NetConnection is part of Windows PowerShell 5.1 and is available on as well as on Windows 10. If you are running PowerShell 7, there is a cross-platform cmdlet called Test-Connection, which provides you with similar capabilities.

I hope this was helpful, and if you have any questions, feel free to leave a comment. What are your favorite PowerShell cmdlets to troubleshoot network connectivity issues?

 

This article was originally published by Microsoft's Premier Field Engineering Blog. You can find the original article here.