Use PowerShell to test a TCP port

Have you ever found yourself in a situation where you want to do a port test from a Windows server to another machine only to find that the Telnet client was not installed?

As from PowerShell 4 (Windows 8.1 / Windows Server 2012 R2) you now have the cmdlet Test-NetConnection which provides you with that functionality.

You can do a simple port test as following:

Test-NetConnection -ComputerName SSA-MSQL01 -Port 1433


You can also test some common protocols like this:

Test-NetConnection -ComputerName SSA-MSQL01 -CommonTCPPort WINRM


And finally, you can also perform a traceroute with this cmdlet:

Test-NetConnection -ComputerName -TraceRoute


Leave a Reply

Your email address will not be published. Required fields are marked *