locked
test-netconnection -traceroute help with adding data RRS feed

  • Question

  • Hello , 

    $a = test-netconnection yahoo.com -tracert  

    gives me the following 

    $a

    ComputerName           : yahoo.com
    RemoteAddress          : 98.138.219.232
    InterfaceAlias         : Wi-Fi
    SourceAddress          : 192.168.1.32
    PingSucceeded          : True
    PingReplyDetails (RTT) : 168 ms
    TraceRoute             : 192.168.1.1
                             109.159.252.172
                             0.0.0.0
                             216.115.100.26
                             216.115.96.7
                             216.115.96.2
                             216.115.104.124
                             216.115.105.181
                             98.138.97.75
                             98.138.0.99
                             98.138.219.232

    what i would like to do is for each of the tracert hops(ip) perform a lookup and then add that name data back into $a , so it can be linked to the correct IP and used later .. 

    any help on this would be greatly appreciated . 

    thanks 


    • Edited by ecco_ecco Wednesday, September 18, 2019 7:17 PM
    Wednesday, September 18, 2019 7:16 PM

Answers

  • Maybe this:

    Test-NetConnection yahoo.com -TraceRoute | 
    	Select -expand TraceRoute | 
    	Select @{ n = 'HostEntry'; e = { [Net.Dns]::GetHostEntry($_)} } | 
    	Select -expand HostEntry
    	


    \_(ツ)_/


    • Edited by jrv Wednesday, September 18, 2019 8:32 PM
    • Marked as answer by ecco_ecco Wednesday, September 18, 2019 8:56 PM
    Wednesday, September 18, 2019 8:31 PM

All replies

  • ... and what's the question?  You might do a step back and read the Forum Posting Guidelines (again) before you proceed.  ;-)

    Live long and prosper!

    (79,108,97,102|%{[char]$_})-join''

    Wednesday, September 18, 2019 8:19 PM
  • "-tracert" is not a valid parameter.

    Use $a.ResolvedAddresses to get the individual IP addresses and use "Add-Member" to add the fqdn to each element of the array.

    Here is a simple example:

    Test-NetConnection yahoo.com -TraceRoute  |
        select -expand TraceRoute | 
        select @{n='fqdn';e={[Net.Dns]::GetHostEntry($_).HostName}}


    \_(ツ)_/

    Wednesday, September 18, 2019 8:28 PM
  • Maybe this:

    Test-NetConnection yahoo.com -TraceRoute | 
    	Select -expand TraceRoute | 
    	Select @{ n = 'HostEntry'; e = { [Net.Dns]::GetHostEntry($_)} } | 
    	Select -expand HostEntry
    	


    \_(ツ)_/


    • Edited by jrv Wednesday, September 18, 2019 8:32 PM
    • Marked as answer by ecco_ecco Wednesday, September 18, 2019 8:56 PM
    Wednesday, September 18, 2019 8:31 PM
  • thanks . another small piece of how it all works falls into place for me with -expand .. 

    :-) 

    Wednesday, September 18, 2019 8:58 PM