How to check if remote ports are open using PowerShell?

Earlier days we were using telnet clients to check the remote port connectivity, in fact, we are still using it with cmd and PowerShell but this feature is not by default installed in OS and some companies have restrictions on installing new features including telnet.

We can leverage PowerShell to test remote port connectivity without installing telnet and with the use of the Test-NetConnection command. This command is also very useful for other diagnostics but we are focusing here for the remote port check.

To check if the remote port is open or not we can use the Test-NetConnection command and it requires -ComputerName parameter and -Port to check the remote port status.

Test-NetConnection -ComputerName Test1-Win2k12 -Port 80


ComputerName     : Test1-Win2k12
RemoteAddress    :
RemotePort       : 80
InterfaceAlias   : Ethernet0
SourceAddress    :
TcpTestSucceeded : True

The above example will check Port number 80 con

ectivity on remote server Test1-Win2k12. You can see that the TcpTestSucceeded property is true so the port is open. One more example shown below is WInRM https port 5986.

Test-NetConnection -ComputerName Test1-Win2k12 -Port 5986


WARNING: TCP connect to Test1-Win2k12:5986 failed
ComputerName           : Test1-Win2k12
RemoteAddress          : RemotePort : 5986
InterfaceAlias         : Ethernet0
SourceAddress          :
PingSucceeded          : True
PingReplyDetails (RTT) : 0 ms
TcpTestSucceeded       : False

You can see that the WinRM SSL port is not open on the remote server and a warning message is displayed in the first line as well as in the TcpTestSucceeded property.