Using PowerShell to verify if a remote TCP port is accessible

A handy tip for any DBA out there who would like to check if a remote TCP port can be connected to but they don’t have access to telnet.

 

The catch is that you require a minimum of Windows 8.1, Windows PowerShell 4.0 or Windows Server 2012 R2. Also, notice I didn’t say check a remote UDP port.

 

You can check your PowerShell version using:

$PSVersionTable.PSVersion

image01

 

Simply open a PowerShell prompt and using Test-NetConnection specify the destination server and TCP port e.g.

Test-NetConnection -ComputerName SQLServer01 -Port 1433

image02

 

If that is too long to type, you can use the alias:

TNC -ComputerName SQLServer01 -Port 1433

image03

 

If you don’t want all that information use:

TNC -ComputerName SQLServer01 -Port 1433 -InformationLevel Quiet

image04

 

You may receive a Ping TimedOut warning but the TcpTestSucceeded is True, which seems confusing. image05

 

This simply means that the ICMP Ping is being blocked. Check with your System Administrator if they would like Ping capability enabled. image06

Leave a Reply to Anonymous Cancel reply