%3CLINGO-SUB%20id%3D%22lingo-sub-1500934%22%20slang%3D%22en-US%22%3EHow%20to%20Troubleshoot%20Windows%20Server%20Network%20connectivity%20issues%20via%20PowerShell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1500934%22%20slang%3D%22en-US%22%3E%3CP%3EWe%20all%20have%20been%20there%2C%20we%20want%20to%20set%20up%20a%20new%20application%20or%20agent%20which%20needs%20network%20access%20and%20needs%20to%20reach%20an%20endpoint%20using%20a%20specific%20port%2C%20but%20it%20simply%20doesn't%20work.%20So%20as%20a%20server%20admin%2C%20we%20need%20to%20have%20a%20tool%20to%20troubleshoot%20network%20connectivity%20issues%20on%20Windows%20Server%20to%20figure%20out%20is%20DNS%20working%2C%20is%20the%20remote%20endpoint%20even%20reachable%2C%20is%20the%20port%20open%2C%20and%20many%20other%20things.%20Luckily%2C%20Windows%20Server%20comes%20with%20PowerShell%20and%20has%20build-in%20cmdlets%20to%20help%20with%20that.%20My%20favorite%20PowerShell%20cmdlet%20to%20troubleshoot%20network%20connectivity%20issues%20is%20Test-NetConnection.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EThe%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3ETest-NetConnection%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3Bcmdlet%20displays%20diagnostic%20information%20for%20a%20connection.%20It%20supports%20ping%20test%2C%20TCP%20test%2C%20route%20tracing%2C%20and%20route%20selection%20diagnostics.%20Depending%20on%20the%20input%20parameters%2C%20the%20output%20can%20include%20the%20DNS%20lookup%20results%2C%20a%20list%20of%20IP%20interfaces%2C%20IPsec%20rules%2C%20route%2Fsource%20address%20selection%20results%2C%20and%2For%20confirmation%20of%20connection%20establishment.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EYou%20can%20do%20simple%20things%2C%20like%20just%20testing%20ping%20connectivity%3A%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3ETest-NetConnection%20itopstalk.com%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EBut%20you%20can%20also%20get%20some%20more%20detailed%20information%20on%20the%20connectivity%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3ETest-NetConnection%20itopstalk.com%20-InformationLevel%20%22Detailed%22%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22PowerShell%20Test-NetConnection%20cmdlet.jpg%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F202531iBA572FF7717CCFFE%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22PowerShell%20Test-NetConnection%20cmdlet.jpg%22%20alt%3D%22PowerShell%20Test-NetConnection%20cmdlet%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EPowerShell%20Test-NetConnection%20cmdlet%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EHowever%2C%20there%20is%20more!%20One%20of%20the%20commands%20I%20need%20the%20most%2C%20especially%20when%20working%20with%20web%20services%2C%20is%20to%20test%20a%20specific%20TCP%20port.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3ETest-NetConnection%20itopstalk.com%20-Port%20443%20-InformationLevel%20%22Detailed%22%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22Test%20TCP%20Port%20using%20PowerShell.jpg%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F202532iCAE3E70BA2024986%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22Test%20TCP%20Port%20using%20PowerShell.jpg%22%20alt%3D%22Test%20TCP%20Port%20using%20PowerShell%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3ETest%20TCP%20Port%20using%20PowerShell%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20can%20also%20perform%20route%20diagnostics%20to%20connect%20to%20a%20remote%20host.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3ETest-NetConnection%20-ComputerName%20itopstalk.com%20-DiagnoseRouting%20-InformationLevel%20Detailed%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22PowerShell%20Diagnose%20Routing.jpg%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F202533iC6853714ABA5A8DE%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22PowerShell%20Diagnose%20Routing.jpg%22%20alt%3D%22PowerShell%20Diagnose%20Routing%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EPowerShell%20Diagnose%20Routing%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20you%20want%20to%20learn%20more%20about%20the%20Test-NetConnection%20cmdlet%20to%20troubleshoot%20network%20connectivity%20issues%2C%20check%20out%20-ERR%3AREF-NOT-FOUND-Microsoft%20Docs.%3C%2FP%3E%0A%3CP%3ETest-NetConnection%20is%20part%20of%20Windows%20PowerShell%205.1%20and%20is%20available%20on%20Windows%20Server%20as%20well%20as%20on%20Windows%2010.%20If%20you%20are%20running%20-ERR%3AREF-NOT-FOUND-PowerShell%207%2C%20there%20is%20a%20cross-platform%20cmdlet%20called%20-ERR%3AREF-NOT-FOUND-Test-Connection%2C%20which%20provides%20you%20with%20similar%20capabilities.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%20hope%20this%20was%20helpful%2C%20and%20if%20you%20have%20any%20questions%2C%20feel%20free%20to%20leave%20a%20comment.%20What%20are%20your%20favorite%20PowerShell%20cmdlets%20to%20troubleshoot%20network%20connectivity%20issues%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-1500934%22%20slang%3D%22en-US%22%3E%3CP%3EHere%20is%20how%20you%20can%20troubleshoot%20network%20connectivity%20issues%20on%20Windows%20Server%20using%20PowerShell%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1500934%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPowerShell%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESecurity%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EThomas%20Maurer%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EWindows%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EWindows%20Server%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Microsoft

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 troubleshoot network connectivity issues on Windows Server to figure out is DNS working, is the remote endpoint even reachable, is the port open, and many other things. Luckily, Windows Server comes with PowerShell and has build-in cmdlets to help with that. My favorite PowerShell cmdlet to troubleshoot network connectivity issues is Test-NetConnection.

 

The Test-NetConnection cmdlet displays diagnostic information for a connection. It supports ping test, TCP 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 TCP port.

 

 

Test-NetConnection itopstalk.com -Port 443 -InformationLevel "Detailed"

 

 

Test TCP Port using PowerShellTest TCP 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 troubleshoot network connectivity issues, check out Microsoft Docs.

Test-NetConnection is part of Windows PowerShell 5.1 and is available on Windows Server 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?