Test-NetConnection

One of the Cmdlet that I use often at work lately is Test-NetConnection. This one is good for your sanity check when you want your server to start to communicate with different endpoints. It supports ping test, TCP test, route tracing, and route selection diagnostics. 

$ Test-NetConnection -ComputerName google.com
ComputerName           : google.com
RemoteAddress          : 172.217.3.174
InterfaceAlias         : Ethernet
SourceAddress          : 192.168.1.23
PingSucceeded          : True
PingReplyDetails (RTT) : 14 ms

If you want to check if certain port is open, you can add -Port parameter to the command above and it checks the specified port.

$ Test-NetConnection -ComputerName google.com -Port 80
ComputerName     : google.com
RemoteAddress    : 172.217.3.174
RemotePort       : 80
InterfaceAlias   : Ethernet
SourceAddress    : 192.168.1.23
TcpTestSucceeded : True

Notice that TcpTestSucceeded data is True now. It means the current machine can reach the port 80 of the endpoint.

Author: admin

A software engineer in greater Seattle area

Leave a Reply

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