PowerShell: Troubleshoot network connectivity

A while back, a customer contacted us because they were having problems connecting to Amazon WorkSpaces. This led me to dig into a PowerShell command which was new to me; Test-NetConnection. In its simplest form, the command simply checks your network connectivity:

Picture of text:

PS C:\Users\ > Test-NetConnection


ComputerName           : internetbeacon.msedge.net
RemoteAddress          : 13.107.4.52
InterfaceAlias         : Wi-Fi
SourceAddress          : 10.202.99.222
PingSucceeded          : True
PingReplyDetails (RTT) : 4 ms

I, however, needed to confirm that I was able to connect to a specific computer, and so added the -ComputerName parameter, and added the appropriate value:

Picture of text:

PS C:\Users\ > Test-NetConnection -ComputerName "workspaces.us-east-1.amazonaws.com"


ComputerName           : workspaces.us-east-1.amazonaws.com
RemoteAddress          : 52.94.234.5
InterfaceAlias         : Wi-Fi
SourceAddress          : 10.202.99.222
PingSucceeded          : True
PingReplyDetails (RTT) : 110 ms

Having confirmed that I was able to connect using the default port, I next needed to check whether the same was true for the ports specified in the documentation. Adding a second parameter, -port, with the appropriate value achieved this nicely:

Picture of text:

PS C:\Users\ > Test-NetConnection -ComputerName "workspaces.us-east-1.amazonaws.com" -port 443
Test-NetConnection -ComputerName "workspaces.us-east-1.amazonaws.com" -port 4172
Test-NetConnection -ComputerName "workspaces.us-east-1.amazonaws.com" -port 4195


ComputerName     : workspaces.us-east-1.amazonaws.com
RemoteAddress    : 52.94.226.108
RemotePort       : 443
InterfaceAlias   : Wi-Fi
SourceAddress    : 10.202.99.222
TcpTestSucceeded : True

WARNING: TCP connect to (52.94.226.108 : 4172) failed
ComputerName           : workspaces.us-east-1.amazonaws.com
RemoteAddress          : 52.94.226.108
RemotePort             : 4172
InterfaceAlias         : Wi-Fi
SourceAddress          : 10.202.99.222
PingSucceeded          : True
PingReplyDetails (RTT) : 102 ms
TcpTestSucceeded       : False

WARNING: TCP connect to (52.94.226.108 : 4195) failed
ComputerName           : workspaces.us-east-1.amazonaws.com
RemoteAddress          : 52.94.226.108
RemotePort             : 4195
InterfaceAlias         : Wi-Fi
SourceAddress          : 10.202.99.222
PingSucceeded          : True
PingReplyDetails (RTT) : 101 ms
TcpTestSucceeded       : False

Honestly, this only scratches the very basics of what we can do with Test-NetConnection, and I’m sure I’ll play around more with it in the future.


Posted

in

,

by

Comments

By posting a comment, you consent to our collecting the information you enter. See privacy policy for more information.

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