Get-NetRoute
Use Get-NetRoute to list the machine's IP routing table entries with their destinations and metrics.
Documentation: Microsoft Learn — PowerShell module reference
Syntax
See the command anatomy
Read the command and its supplied arguments. This example requires real PowerShell or its module; this diagram does not execute it.
Get-NetRoute [[-DestinationPrefix] <string[]>] [-InterfaceIndex <UInt32[]>] [-InterfaceAlias <String[]>] [-AddressFamily <AddressFamily[]>] [-NextHop <String[]>] [-CimSession <CimSession[]>] [<CommonParameters>]- Stage 1Get-NetRoute
-DestinationPrefix -InterfaceIndex -InterfaceAlias -AddressFamily -NextHop -CimSession
Try it
PowerShell example · browser support is limited.
Execution scope: The full example below requires PowerShell outside this browser. You can edit this runner to use the supported practice commands; unsupported syntax returns an explanation.
Follow the objects
Run the command to inspect each stage.
Examples
Get-NetRoute -DestinationPrefix 0.0.0.0/0
Show reference output
Sample output · fictional data, shaped like the real thing
InterfaceAlias NextHop RouteMetric
-------------- ---------- -----------
10.20.30.1 25
0.0.0.0 256Sort by RouteMetric
Show reference output
Sample output · fictional data, shaped like the real thing
DestinationPrefix NextHop RouteMetric ----------------- ---------- ----------- 0.0.0.0/0 10.20.30.1 25 10.20.30.0/24 0.0.0.0 256
Get-NetRoute -InterfaceIndex 12
Show reference output
Sample output · fictional data, shaped like the real thing
Count : 2 Average : Sum : Maximum : Minimum : Property :
Parameters
Parameter definitions:
-DestinationPrefix-InterfaceIndex-InterfaceAlias-AddressFamily-NextHop-CimSession
Practical use and troubleshooting
Practical scenario: Use Get-NetRoute when you need to list the machine's IP routing table entries with their destinations and metrics. Start with one identified target and inspect the returned values before extending the operation to a list. Keep the identity in your report so you can trace each result back to the object or path that produced it.
Common error and fix: An unexpected route may belong to another interface or policy store. Inspect DestinationPrefix, NextHop and InterfaceIndex before interpreting it as the path for your target. In an unattended script, capture this failure with its original error record and record which target failed. An empty result and an unsuccessful query must remain distinguishable in the final report.
See also: Test-NetConnection. Get-NetRoute reads routing entries; Test-NetConnection performs supported reachability checks. A stored route is configuration, not proof that the destination accepted a connection. Read the linked command before substituting it; similar names do not imply identical inputs or output.
Recap
Get-NetRoute Use Get-NetRoute to list the machine's IP routing table entries with their destinations and metrics.
Next: Get-LocalUser