PowerShell Logo Small

Set-NetRoute



This is the built-in help made by Microsoft for the command 'Set-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

Modifies an entry or entries in the IP routing table.

SYNTAX


Set-NetRoute [[-DestinationPrefix] <String[]>] [-AddressFamily <AddressFamily[]>] [-AsJob [<SwitchParameter>]] [-CimSession <CimSession[]>]
[-InterfaceAlias <String[]>] [-InterfaceIndex <UInt32[]>] [-NextHop <String[]>] [-PassThru [<SwitchParameter>]] [-PolicyStore <String>]
[-PreferredLifetime <TimeSpan>] [-Publish <Publish>] [-RouteMetric <UInt16>] [-ThrottleLimit <Int32>] [-ValidLifetime <TimeSpan>] [-Confirm
[<SwitchParameter>]] [-WhatIf [<SwitchParameter>]] [<CommonParameters>]
Set-NetRoute [-AsJob [<SwitchParameter>]] [-CimSession <CimSession[]>] [-PassThru [<SwitchParameter>]] [-PreferredLifetime <TimeSpan>]
[-Publish <Publish>] [-RouteMetric <UInt16>] [-ThrottleLimit <Int32>] [-ValidLifetime <TimeSpan>] -InputObject <CimInstance[]> [-Confirm
[<SwitchParameter>]] [-WhatIf [<SwitchParameter>]] [<CommonParameters>]



Search powershellhelp.space

DESCRIPTION


The Set-NetRoute cmdlet modifies an entry or entries in the IP routing table. This cmdlet has 2 types of parameters. One set of parameters
specifies the routing table entry or entries to be modified. A destination prefix must be used and next hop address must be used as an
identifier and additional properties may be included such as InterfaceIndex. The second set of parameters modifies properties in that
NetIPAddress object. These properties include Type, PrefixLength, valid or preferred lifetime and skip as source.


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.


NetRoute objects do not allow the DestinationPrefix or NextHop properties to be modified after creation. To modify these values, remove the
NetRoute object and re-create it using the New-NetRoute cmdlet.


Note: A gateway is a routing concept covered by the Get-NetRoute cmdlet. For IP end points, 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, the Get-NetRoute cmdlet modifies the routing table for all of the routes on the computer.



<

RELATED LINKS

Get-NetRoute
New-NetRoute
Remove-NetRoute
New-TimeSpan

REMARKS

<

Examples


EXAMPLE 1

PS C:\>Set-NetRoute –RouteMetric 257



This example sets the RouteMetric parameter to 257, making the route less preferable than the default of 256.




EXAMPLE 2

PS C:\>$timespan = ( New-TimeSpan –Days 1 )



PS C:\>Set-NetRoute –DestinationPrefix 192.168.0.0/24 –PreferredLifetime $timespan



This example sets the PreferredLifetime parameter to one (1) day.