Categories
How-To Technical

Tech Short: PowerShell: Networking Diagnostics

Listen ‘tracert’ its not you, its me…  I am not ending my long term relationship with the diagnostic tools which I have used for many years now.  I am just exploring others, and in doing so going on a “break”.

I recently starting using PowerShell more often and wondered is there a tool which can do what ‘tracert‘ does and maybe more.

This is where the PowerShell command  Test-NetConnection comes into the picture.

It does many of the functions of tracert which an out-put which at this point I favor far more.

Here are some examples:

Here is an example of using Test-NetConnection to test connectivity to jermsmit.com

Test-NetConnection jermsmit.com

ComputerName : jermsmit.com
RemoteAddress : 184.168.16.1
InterfaceAlias : Wi-Fi
SourceAddress : 1.2.3.150
PingSucceeded : True
PingReplyDetails (RTT) : 80 ms

 

Same test as above using the –TraceRoute flag return the list of hosts on the path to the specified target jermsmit.com

Test-NetConnection jermsmit.com -TraceRoute

ComputerName : jermsmit.com
RemoteAddress : 184.168.16.1
InterfaceAlias : Wi-Fi
SourceAddress : 1.2.3.150
PingSucceeded : True
PingReplyDetails (RTT) : 82 ms
TraceRoute :
1..2.3.150
96.120.75.45
68.86.221.197
68.86.209.165
68.86.90.21
68.86.85.53
68.86.85.25
68.86.83.82
173.167.58.134
184.168.0.69
184.168.0.69
97.74.255.129
184.168.16.1

As you can see form the examples its a very useful tool in PowerShell, also giving you information about which network interface you are testing from.

What I have also found out is there is an alias for  Test-NetConnection. To use this all you need to do is simply type ‘tnr‘ following by the command syntax.

For more info on using Test-NetConnection type: Help Test-NetConnection in the PowerShell command prompt – Results may looking similar to what I have shown below:

 

PS C:\Windows\system32> Help Test-NetConnection

NAME
    Test-NetConnection
    
SYNTAX
    Test-NetConnection [[-ComputerName] <string>] [-TraceRoute] [-Hops <int>] 
    [-InformationLevel <string> {Quiet | Detailed}]  [<CommonParameters>]
    
    Test-NetConnection [[-ComputerName] <string>] [-CommonTCPPort] <string> {HTTP | RDP | SMB | 
    WINRM} [-InformationLevel <string> {Quiet | Detailed}]  [<CommonParameters>]
    
    Test-NetConnection [[-ComputerName] <string>] -Port <int> [-InformationLevel <string> 
    {Quiet | Detailed}]  [<CommonParameters>]
    

ALIASES
    TNC
    

REMARKS
    Get-Help cannot find the Help files for this cmdlet on this computer. It is displaying only 
    partial help.
        -- To download and install Help files for the module that includes this cmdlet, use 
    Update-Help.

 

 

 I hope you enjoyed this techshort, thanks for visiting – jermal

 

Leave a Reply

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

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