COMMAND EVERYTHING.
Modifies an entry or entries in the IP routing table.
Microsoft NetTCPIP reference: Modifies an entry or entries in the IP routing table. The syntax and selected example below are adapted from the pinned Windows Server 2025 reference. Module availability, target configuration and delegated permissions determine whether it can run in your environment. Documentation and parameter text: Microsoft, CC BY 4.0; formatting adapted by Cmdlet World. No execution testing is claimed.
Use an account with the target resource permissions documented for Set-NetRoute. Modifying administrative cmdlets may require elevation or delegated administration. This catalog does not assert that ordinary users can execute the command.
Windows / NetTCPIP · Windows Server 2025 documentation; feature/module prerequisites apply
-AddressFamily- Specifies an array of IP address families of IP routes. The cmdlet modifies the family that you specify for the IP route. The acceptable values for this parameter are: - IPv4 - IPv6
-AsJob- Runs the cmdlet as a background job. Use this parameter to run commands that take a long time to complete.
-CimSession- Runs the cmdlet in a remote session or on a remote computer. Enter a computer name or a session object, such as the output of a New-CimSession or Get-CimSession cmdlet. The default is the current session on the local computer.
-Confirm- Prompts you for confirmation before running the cmdlet.
-DestinationPrefix- Specifies an array of destination prefixes of IP routes. The cmdlet modifies settings for this IP route. A destination prefix contains an IP address prefix and a prefix length, separated by a slash (/). A value of 0.0.0.0/0 for IPv4 or ::/0 for IPv6 indicates that the value of the *NextHop* parameter is a default gateway.
-IncludeAllCompartments- Indicates that the cmdlet includes routes from all configured network compartments. If you do not specify this parameter, the cmdlet modifies only routes in the default network compartment.
-InputObject (required)- Specifies the input object that is used in a pipeline command.
-InterfaceAlias- Specifies an array of aliases of network interfaces. The cmdlet modifies IP routes for the interfaces that have the aliases that you specify.
-InterfaceIndex- Specifies an array of indexes of network interfaces. The cmdlet modifies IP routes for the interfaces located at the indexes that you specify.
-NextHop- Specifies an array of next hop values. The cmdlet modifies the routes that have these values. A value of 0.0.0.0 for IPv4 or :: for IPv6 indicates that the route is on the local subnet.
-PassThru- Returns an object representing the item with which you are working. By default, this cmdlet does not generate any output.
-PolicyStore- Specifies a PolicyStore value. The cmdlet changes the PolicyStore value to the value that you specify. The acceptable values for this parameter are: - ActiveStore. The IP address information is valid. - PersistentStore. The computer saves IP address information across restarts. When the computer restarts, it copies the saved settings to the ActiveStore. Specify ActiveStore only. If you do not specify this parameter, the default entries are created in both the ActiveStore and the PersistentStore.
-PreferredLifetime- Specifies a preferred lifetime, as a TimeSpan object, of an IP route. The cmdlet changes the lifetime to the value that you specify. To obtain a TimeSpan object, use the New-TimeSpan cmdlet. For more information, type Get-Help New-TimeSpan.
-Protocol- Specifies an array of types of routing protocols. The cmdlet changes the protocol to the value you specify. The acceptable values for this parameter are: - Bbn - Bgp - Dhcp - Dvmrp - Egp - Eigrp - EsIs - Ggp - Hello - Icmp - Idpr - Igrp - IsIs - Local - NetMgmt - Ospf - Rip - Rpl - Other
-Publish- Specifies the publish setting of an IP route. The cmdlet changes the publish value to the value that you specify. The acceptable values for this parameter are: - No. Do not publish or advertise IP route information in router advertisements. - Yes. Publish and advertise IP route information with an infinite valid lifetime in router advertisements. - Age. Publish and advertise IP route information with a finite valid lifetime, in router advertisements. Specify a valid lifetime by using the ValidLifetime parameter.
-RouteMetric- Specifies an integer route metric for an IP route. The cmdlet changes the metric to the value that you specify. To choose among multiple routes, the computer adds this value to the interface metric value. The computer selects the route with the lowest combined value. To modify the interface metric, use the Set-NetIPInterface cmdlet.
-ThrottleLimit- Specifies the maximum number of concurrent operations that can be established to run the cmdlet. If this parameter is omitted or a value of 0 is entered, then Windows PowerShell® calculates an optimum throttle limit for the cmdlet based on the number of CIM cmdlets that are running on the computer. The throttle limit applies only to the current cmdlet, not to the session or to the computer.
-ValidLifetime- Specifies a valid lifetime, as a TimeSpan object, for an IP route. The cmdlet changes the lifetime to the value that you specify. To obtain a TimeSpan object, use the New-TimeSpan cmdlet.
-WhatIf- Shows what would happen if the cmdlet runs. The cmdlet is not run.
Windows with the NetTCPIP module and the Windows feature or management tools that provide it. Confirm target connectivity and version compatibility using the linked Microsoft reference.
This cmdlet changes system state. Review every target and parameter in the official reference, test outside production, and prepare an appropriate backup or rollback. Do not execute the example automatically.