TL;DR: Test-NetConnection -TraceRoute is PowerShell’s equivalent of tracert: Both show the network path to a destination hop by hop. Tracert is better when you need round-trip time data, while Test-NetConnection -TraceRoute is better for PowerShell automation, supports options like -Hops and detailed output, and can be looped across multiple targets and exported to a log file.
The PowerShell equivalent of tracert is the Test-NetConnection -TraceRoute cmdlet. Tracert traces the path of network packets to a destination, showing each hop along the route. This guide explains how tracert works and how to run its PowerShell alternative with practical examples.
Ever wonder what all that data traveling back and forth across the internet looks like? Or how about that email titled "Re: Re: Fwd: Fwd: Re: Fwd: Fwd: Fwd: Funny cat video!" actually getting from your dad's computer at The Villages in Florida, all the way to your smartphone's spam folder? Well, you're in luck. We're covering a network utility that allows you to trace all that precious data as it travels the interwebs.
What is tracert?
Tracert is a Windows command-line utility that traces the path packets take to a destination. It shows each router hop between your device and the target host, which helps troubleshoot routing problems and latency issues.
I like to compare tracert to following the tracking information after ordering a super sweet Three Wolf Moon t-shirt online. The tracking record updates each time the precious cargo reaches a new courier facility so you can follow your package's path. Tracert works similarly, just with network packets instead of t-shirts with three wolves howling at the moon.
How do you run tracert in Windows?
To run tracert in Windows, open Command Prompt or PowerShell and enter tracert followed by a hostname or destination IP address.
tracert <hostname/ip address>
As you can see, I've done a tracert to PDQ.com. The first column is the hop count. This route took seven hops. The second, third, and fourth columns are the RTT or round trip times it took for the packets to reach the router and then return. Tracert sends out three packets, which is why there are three columns. The RTT is recorded in milliseconds (ms). The last column is the IP address of the router encountered on the route.
If you encounter unusually high return times, such as several hundred milliseconds, that may indicate an issue with the route, such as an improperly configured or malfunctioning router.
Now let's look at the PowerShell equivalent of tracert.
What is the PowerShell equivalent of tracert?
The PowerShell equivalent of tracert is Test-NetConnection -TraceRoute. It traces the route to a destination hop by hop and is better suited for scripting than the legacy tracert command.
Run PowerShell scripts on remote devices
Execute PowerShell scripts on managed devices from anywhere with PDQ Connect.
Test-NetConnection -TraceRoute
NAME
Test-NetConnection
SYNTAX
Test-NetConnection [[-ComputerName] <string>] [-TraceRoute] [-Hops <int>] [-InformationLevel {Quiet |
Detailed}] [<CommonParameters>]
Test-NetConnection [[-ComputerName] <string>] [-CommonTCPPort] {HTTP | RDP | SMB | WINRM}
[-InformationLevel {Quiet | Detailed}] [<CommonParameters>]
Test-NetConnection [[-ComputerName] <string>] -Port <int> [-InformationLevel {Quiet | Detailed}]
[<CommonParameters>]
Test-NetConnection [[-ComputerName] <string>] -DiagnoseRouting [-ConstrainSourceAddress <string>]
[-ConstrainInterface <uint32>] [-InformationLevel {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.You'll notice that this one is a bit different than some of the other commands I've covered in the past. That's because this command actually includes a switch with the base command. The base command Test-NetConnection displays diagnostic information for a connection. You'll need to include the -TraceRoute switch in order to perform the route tracing.
Let's take a look at a couple of examples.
Test-NetConnection -TraceRoute example 1
Run the basic PowerShell equivalent of tracert using Test-NetConnection -TraceRoute to display each hop to the destination.
Test-NetConnection -TraceRoute "destination"
This is the basic PowerShell route tracing command. It shows the routers contacted on the way to the destination, but unlike tracert, it does not return round-trip time (RTT) for each hop by default.
When you run this command, you'll also notice a status bar appears briefly while the route is traced.

This status bar gives you a little more insight into the details of the route trace.
ICMP Echo Request is the type of request being sent. ICMP stands for Internet Control Message Protocol, and these types of messages are primarily used for diagnostic purposes.
Max TTL = 30 means the trace will check up to 30 hops on the way to the destination. Think of TTL as a built-in safety rail: It keeps the trace from wandering around the network forever if it runs into a routing loop or some other weirdness. Traceroute works by sending packets with a TTL that starts at 1 and increases with each round of probes. Every time a packet passes through a router, that router knocks the TTL down by 1. When the TTL hits 0, the router sends back a reply, which is how the command reveals each hop along the route. If the destination still hasn’t been reached by the time the trace hits the 30-hop limit, the trace stops.
TTL = 7 means the destination was reached in 7 hops.
Test-NetConnection -TraceRoute example 2
Add the -Hops and -InformationLevel Detailed switches to control the maximum number of hops and return more diagnostic details.
Test-NetConnection -TraceRoute "destination" -Hops "int" -InformationLevel Detailed
In this example, you'll notice that I added a couple of additional switches. The -Hops switch allows users to set the maximum number of hops or TTL for the trace route. In the example above, I set my maximum number of hops to three, which, as you can see, caused my trace route to fail because it needed more hops to reach the destination. The -InformationLevel Detailed switch returns additional information about the trace route.
Test-NetConnection -TraceRoute example 3
Use a loop with Test-NetConnection -TraceRoute to run traceroutes against multiple destinations and export the results to a log file.
$List = "google.com","pdq.com","yahoo.com"
$output = ForEach ($Destination in $List){
Test-NetConnection -ComputerName $Destination -TraceRoute
}
$output | Out-File -FilePath "C:\Logs\trace_route.txt"
In this example, we are running the traceroute command against multiple destinations and exporting the results to a log file. First, we assign multiple destinations to the $List variable. Next, we use a ForEach loop to run the traceroute command against each destination in the $List variable and then assign the results of each loop to the $output variable. Lastly, we use the Out-File command to send the results contained in the $output variable to a text file.
Should you use tracert or PowerShell Test-NetConnection?
Tracert is better for round-trip time (RTT) visibility, while Test-NetConnection -TraceRoute offers PowerShell integration but lacks RTT output. Use tracert if you need latency details; use PowerShell if you need automation or scripting flexibility.
Looking for more ways to automate admin work in Windows environments? PDQ Connect and PDQ Deploy & Inventory help teams run scripts, manage devices, and reduce repetitive manual tasks. Sign up for a free 14-day trial of our products to discover how we can help alleviate the stress of keeping your computers up to date.




