PowerShell Logo Small

Set-NetRoute



This is the built-in help made by Microsoft for the command 'Set-NetRoute', in PowerShell version 5 - as retrieved from Windows version 'Microsoft Windows Server 2012 R2 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] [-CimSession <CimSession[]>] [-IncludeAllCompartments] [-InterfaceAlias
<String[]>] [-InterfaceIndex <UInt32[]>] [-NextHop <String[]>] [-PassThru] [-PolicyStore <String>] [-PreferredLifetime <TimeSpan>] [-Protocol <Protocol[]>] [-Publish
<Publish>] [-RouteMetric <UInt16>] [-ThrottleLimit <Int32>] [-ValidLifetime <TimeSpan>] [-Confirm] [-WhatIf] [<CommonParameters>]
Set-NetRoute [-AsJob] [-CimSession <CimSession[]>] [-PassThru] [-PreferredLifetime <TimeSpan>] [-Publish <Publish>] [-RouteMetric <UInt16>] [-ThrottleLimit <Int32>]
[-ValidLifetime <TimeSpan>] -InputObject <CimInstance[]> [-Confirm] [-WhatIf] [<CommonParameters>]



Search powershellhelp.space

DESCRIPTION


The Set-NetRoute cmdlet modifies entries in the IP routing table. Specify routes to modify by using the DestinationPrefix parameter or the NextHop parameter. You can also
specify routes by using the Get-NetRoute cmdlet. If you do not specify which routes to modify, the cmdlets modifies all of the routes on the computer.


IP routing is the process of forwarding a packet based on the destination IP address. Routing occurs at TCP/IP hosts and at IP routers. The sending host or router determines
where to forward the packet. To determine where to forward a packet, the host or router consults a routing table that is stored in memory. When TCP/IP starts, it creates
entries in the routing table. You can add entries either manually or automatically.


For more information about routing, see Chapter 5 - IP Routing (http://technet.microsoft.com/library/bb727001.aspx) in the TechNet library.


After you create an entry in the routing table, you cannot modify the destination prefix or the next hop value. If necessary, use the Remove-NetRoute cmdlet to remove the
entry, and then recreate it with the desired values by using the New-NetRoute cmdlet.



<

RELATED LINKS

Online Version: http://go.microsoft.com/fwlink/?LinkID=289171
Find-NetRoute
Get-NetRoute
New-NetRoute
Remove-NetRoute
Set-NetIPInterface
New-TimeSpan

REMARKS

<

Examples


Example 1: Change the route metric

PS C:\>Set-NetRoute –RouteMetric 257



This command changes the route metric to 257. This route is less preferred than routes that have the default value of 256.




Example 2: Modify the preferred lifetime

PS C:\> $TimeSpan = New-TimeSpan –Days 1
PS C:\> Set-NetRoute –DestinationPrefix "192.168.0.0/24" –PreferredLifetime $TimeSpan



The first command uses the New-TimeSpan cmdlet to create a time span of one day, and then stores it in the $TimeSpan variable. For more information, type Get-Help
New-TimeSpan.

The second command changes the lifetime of the IP route that has the destination prefix 192.168.0.0/24. The command specifies the object stored in the $TimeSpan variable as
the new preferred lifetime.