Is there a PowerShell equivalent tracert that works in version 2? – Stack Overflow

Test-NetConnection “IPaddress/HOSTaname” -TraceRoute

Source: Is there a PowerShell equivalent tracert that works in version 2? – Stack Overflow

Make a function for trace route
function Invoke-Tracert {
param([string]$RemoteHost)

tracert $RemoteHost |ForEach-Object{
if($_.Trim() -match “Tracing route to .*”) {
Write-Host $_ -ForegroundColor Green
} elseif ($_.Trim() -match “^\d{1,2}\s+”) {
$n,$a1,$a2,$a3,$target,$null = $_.Trim()-split”\s{2,}”
$Properties = @{
Hop = $n;
First = $a1;
Second = $a2;
Third = $a3;
Node = $target
}
New-Object psobject -Property $Properties
}
}
}


Posted

in

by

Tags: