I need a PowerShell script to Tracert an entire range (For Example 10.20.30.[0-255])
And search for a specific Address as one of the hops (For example 10.56.44.12)
and if that address appears, that address will be appended to a simple text file.
Any ideas?
PowershellScripting LanguagesShell ScriptingWindows OS
Last Comment
Dan Craciun
8/22/2022 - Mon
Brian Murphy
Is ICMP enabled?
If so, you could start with tracert -d (no DNS resolution).
I just want to make sure ICMP is not disabled before I suggest next steps for Powershell.
Apologies.
David Sankovsky
ASKER
The computer that will be running the script is open with DMZ to the entire range, and ICMP is certainly enabled on both the sources (10.20.30.0-255) and the Destination 10.56.44.12 (These are example addresses)
There might be addresses in the path that won't answer though.
Also, if it's relevant, we can't assume the required IP Address will always be the same hop.
Brian Murphy
What are we working with?
.NET 4.5.2 with MS Management Framework 4.0 aka Powershell 4 is good.
.NET 4.6 with MS Management Framework 5.0 aka Powershell 5 with DSC better
Well, someone beat me to it. If this works, we should not make a new wheel. I'm not convinced yet it will do what you want, however. Because I'm not sure what that is, yet.
They probably used Sapien Powershell Studio. That is what I used, they compiled a binary script that pings but also gives TTL.
Ping Admin tool is powerful tool based on PowerShell scripting.
Using Power Admin tool you can Ping to Single, multiple Server/computers or IP range.
Moreover, Ping Admin tool gives you OS type as well in the output, along with FQDN and IP address.
If, IP range selected then it will show TTL value as well.
David Sankovsky
ASKER
$PSVersionTable.PSVersion
Major Minor Build Revision
----- ----- ----- --------
5 0 10240 16384
[System.Reflection.Assembly]::GetExecutingAssembly().ImageRuntimeVersion
v4.0.30319
I may have not explained myself properly.
I have a certain range 10.20.30.0\24
I need to use the command tracert -d for each and every address in the range,
Then to scan the output for a certain hop (10.56.44.12 for example) and then to write to a file only those addresses which have that speific address in the trace.
(To make it simpler to understand the point of the exercise, I have two firewalls, both sitting behind Junipers, Some addresses are routed to the old firewall and some to the new. I need to those which are routed to the old one to know which ones I have to migrate. Since the person managing the Juniper Routers is out of the country for the next couple of months, I'll have to do it this way as I have no CLI access to the Juniper router)
Brian Murphy
Much better. Thanks. I did not understand, this helps.
Does all that and more, you just populate your text file with your ranges or CSV and it will export everything out to whatever you want; txt, csv, html.
I run it on Linux and Windows. I have on my MGMT server in the DMZ. Along with a bunch of other cool stuff.
I mean, I'm willing to play but what your asking is not something I can pull off in a day. But I'll help if NMAP is not an option for you.
If so, you could start with tracert -d (no DNS resolution).
I just want to make sure ICMP is not disabled before I suggest next steps for Powershell.
Apologies.