Test-NetConnection my Telnet Replacement

The more I use PowerShell, the more I like it! I saw a Tweet put out by Scott Bollinger (@kfalconspb) about using a PowerShell cmdlet (here) to see if a port is open on a remote system. After reading the quick blog, my first thought was, “No more telnet”.  The PowerShell cmdlet Test-NetConnection followed with a parameter of -port number will test the remote system. Take a look:

Test-NetConnection -ComputerName aws.amazon.com -port 80

ComputerName     : aws.amazon.com
RemoteAddress    :
RemotePort       : 80
InterfaceAlias   : Ethernet
SourceAddress    : <internal IP>
TcpTestSucceeded : True

This looks like good information. I can see port 80 is open because it came back True. What if I want to know the round trip time (RTT) to AWS? Look no further, Test-NetConnection has you covered.

Test-NetConnection -ComputerName aws.amazon.com -InformationLevel Detailed

ComputerName           : aws.amazon.com
RemoteAddress          :
NameResolutionResults  :
InterfaceAlias         : Ethernet
SourceAddress          : <internal IP>
NetRoute (NextHop)     : <internal router>
PingSucceeded          : True
PingReplyDetails (RTT) : 34 ms

Cool! I can see my RTT was 34 ms to get to AWS. This cmdlet arms me with some very powerful information besides pinging the remote host. I can now go back to the system owner with more information than just “yes, it pings”.

I can see putting this in a loop and testing a port on multiple systems or testing a single system and a range of ports to see what’s open and taking action on the results.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.