PowerShell Logo Small

Get-NetRoute



This is the built-in help made by Microsoft for the command 'Get-NetRoute', in PowerShell version 3 - as retrieved from Windows version 'Microsoft Windows Server 2012 Standard' PowerShell help files on 2016-06-23.

For PowerShell version 3 and up, where you have Update-Help, this command was run just before creating the web pages from the help files.

SYNOPSIS

Gets the IP routing table.

SYNTAX


Get-NetRoute [[-DestinationPrefix] <String[]>] [-AddressFamily <AddressFamily[]>] [-AsJob [<SwitchParameter>]] [-AssociatedIPInterface
<CimInstance>] [-CimSession <CimSession[]>] [-InterfaceAlias <String[]>] [-InterfaceIndex <UInt32[]>] [-NextHop <String[]>] [-PolicyStore
<String>] [-PreferredLifetime <TimeSpan[]>] [-Publish <Publish[]>] [-RouteMetric <UInt16[]>] [-ThrottleLimit <Int32>] [-ValidLifetime
<TimeSpan[]>] [<CommonParameters>]



Search powershellhelp.space

DESCRIPTION


The Get-NetRoute cmdlet gets the IP routing table information, including destination network prefixes, Next Hop IP addresses and Route Metrics.


IP routing is the process of forwarding a packet based on the destination IP address. Routing occurs at a sending TCP/IP host and at an IP
router.

In each case, the IP layer at the sending host or router must decide where to forward the packet. For IPv4, routers are also commonly referred
to as gateways. To make these decisions, the IP layer consults a routing table stored in memory. Routing table entries are created by default
when TCP/IP initializes, and entries can be added either manually or automatically. When the computer is routing, the RouteMetric property is
added to the InterfaceMetric property, described as a part of NetIPInterface. This total value is used to decide the pass-through interface to
send the forwarded packets. For more information, see IP Routing on TechNet.


Note: A gateway is a routing concept covered by this cmdlet. For IP endpoints, the gateway specifies the forwarding or next hop IP address
over which the set of addresses defined by the network destination and subnet mask are reachable.


Without parameters, this cmdlet returns the routing table for all routes on the computer.



<

RELATED LINKS

Format-List
Select-Object
Where-Object
New-NetRoute
Remove-NetRoute
Set-NetRoute
Get-NetAdapter

REMARKS

<

Examples


EXAMPLE 1

Used without parameters, this cmdlet gets IP route information for all interfaces.
PS C:\>Get-NetRoute


The default output omits some properties. Run this cmdlet to display all of the fields (all of the properties of the object).
PS C:\>Get-NetRoute | Format-List –Property *



This example gets information about IP route configuration.




EXAMPLE 2

PS C:\>Get-NetRoute –AddressFamily IPv6



This example gets information about the IP route configuration for IPv6 routes.




EXAMPLE 3

PS C:\>Get-NetRoute | Format-List



This example gets information about IP route configuration, and displays more information than the default table view. This includes
properties such as InterfaceAlias, ValidLifetime, and PreferredLifetime.




EXAMPLE 4

PS C:\>Get-NetRoute –InterfaceIndex 12



This example gets information about IP route configuration for all routes that use a specific InterfaceIndex.




EXAMPLE 4

PS C:\>Get-NetRoute –DestinationPrefix "0.0.0.0/0" | Select-Object –Expand NextHop



This example gets the default IP routes, finds one or more NextHop IP addresses, and displays them. Note: The next hop gateway for the default
route is also known as the default gateway.




EXAMPLE 5

PS C:\>Get-NetRoute | Where-Object –FilterScript { $_.NextHop -Ne "::" } | Where-Object –FilterScript { $_.NextHop -Ne "0.0.0.0" } |
Where-Object –FilterScript { ($_.NextHop.SubString(0,6) -Ne "fe80::") }



This example gets information about IP routes that access destinations off-link.




EXAMPLE 6

PS C:\>Get-NetRoute | Where-Object –FilterScript {$_.NextHop -Ne "::"} | Where-Object –FilterScript { $_.NextHop -Ne "0.0.0.0" } |
Where-Object –FilterScript { ($_.NextHop.SubString(0,6) -Ne "fe80::") } | Get-NetAdapter



This example gets information about network adapters that have IP routes that access destinations off-link.




EXAMPLE 7

PS C:\>Get-NetRoute | Where-Object –FilterScript { $_.ValidLifetime -Eq ([TimeSpan]::MaxValue) }


Similarly, this command gets information about IP Routes that do not have an infinite ValidLifetime.
PS C:\>Get-NetRoute | Where-Object –FilterScript { $_.ValidLifetime -Ne ([TimeSpan]::MaxValue) }



This example gets information about IP Routes that have an infinite ValidLifetime.