Skip to content

Commit ed81db4

Browse files
bobbytreedsdwheeler
authored andcommitted
Fixes #4152 - Update examples of Test-Connection with sample output for Traceroute (#4322)
1 parent 8fcf6bb commit ed81db4

File tree

1 file changed

+64
-1
lines changed

1 file changed

+64
-1
lines changed

reference/6/Microsoft.PowerShell.Management/Test-Connection.md

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,69 @@ The value is `$True` if any of the four pings succeed. If none of the pings succ
161161

162162
If the `Test-Connection` command returns a value of `$True`, the command uses the `New-PSSession` cmdlet to create the **PSSession**.
163163

164+
### Example 7: Use the Traceroute parameter
165+
166+
Beginning in PowerShell 6.0, the **Traceroute** parameter maps a route between the local computer
167+
and the remote destination you specify to **TargetName**.
168+
169+
```powershell
170+
Test-Connection -TargetName www.microsoft.com -Traceroute | ForEach-Object {
171+
$_ | Format-Table Source, DestinationAddress, DestinationHost
172+
$_.Replies | ForEach-Object {
173+
$_ | Format-Table Hop, ReplyRouterAddress
174+
$_.PingReplies | Format-Table
175+
}
176+
}
177+
```
178+
179+
```Output
180+
Tracing route to www.microsoft.com [96.6.27.90] over a maximum of 128 hops:
181+
1 0 ms 0 ms 0 ms 192.168.0.3 [192.168.0.3]
182+
2 0 ms 0 ms 0 ms 192.168.1.1 [192.168.1.1]
183+
3 3 ms 29 ms 4 ms 96.6.27.90 [96.6.27.90]
184+
Trace complete.
185+
186+
Source DestinationAddress DestinationHost Replies
187+
------ ------------------ --------------- -------
188+
SERVER01 96.6.27.90 www.microsoft.com {, , }
189+
190+
Hop ReplyRouterAddress
191+
--- ------------------
192+
1 192.168.0.3
193+
194+
Status Address RoundtripTime Options Buffer
195+
------ ------- ------------- ------- ------
196+
TtlExpired 192.168.86.1 0 {}
197+
TtlExpired 192.168.86.1 0 {}
198+
TtlExpired 192.168.86.1 0 {}
199+
200+
Hop ReplyRouterAddress
201+
--- ------------------
202+
2 192.168.1.1
203+
204+
Status Address RoundtripTime Options Buffer
205+
------ ------- ------------- ------- ------
206+
TtlExpired 192.168.1.1 0 {}
207+
TtlExpired 192.168.1.1 0 {}
208+
TtlExpired 192.168.1.1 0 {}
209+
210+
Hop ReplyRouterAddress
211+
--- ------------------
212+
3 96.6.27.90
213+
214+
Status Address RoundtripTime Options Buffer
215+
------ ------- ------------- ------- ------
216+
Success 96.6.27.90 3 System.Net.NetworkInformation.PingOptions {97, 98, 99, 100…}
217+
Success 96.6.27.90 2 System.Net.NetworkInformation.PingOptions {97, 98, 99, 100…}
218+
Success 96.6.27.90 4 System.Net.NetworkInformation.PingOptions {97, 98, 99, 100…}
219+
```
220+
221+
The first command calls the `Test-Connection` cmdlet with the **Traceroute** parameter. The results,
222+
which are `[Microsoft.PowerShell.Commands.TestConnectionCommand+TraceRouteResult]` objects are piped
223+
to the `ForEach-Object` cmdlet, which creates a structured output of the contained
224+
`[Microsoft.PowerShell.Commands.TestConnectionCommand+TraceRouteReply]` objects and subsequent
225+
`[System.Net.NetworkInformation.PingReply]` objects.
226+
164227
## PARAMETERS
165228

166229
### -BufferSize
@@ -475,4 +538,4 @@ Otherwise, this cmdlet returns the object type specific to the test.
475538

476539
[Restart-Computer](Restart-Computer.md)
477540

478-
[Stop-Computer](Stop-Computer.md)
541+
[Stop-Computer](Stop-Computer.md)

0 commit comments

Comments
 (0)