Remove-NetRoute

Remove-NetRoute

Deletes an entry or entries (IP routes) from the IP routing table.

Syntax

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

Parameter Set: InputObject (cdxml)
Remove-NetRoute -InputObject <CimInstance[]> [-AsJob] [-CimSession <CimSession[]> ] [-PassThru] [-ThrottleLimit <Int32> ] [-Confirm] [-WhatIf] [ <CommonParameters>]

Detailed Description

The Remove-NetRoute cmdlet deletes an entry or entries from the IP routing table, including destination network prefixes, Next Hop IP addresses and Route Metrics. Parameters can be used to specify a set of routes to delete.

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.

Without parameters, the Get-NetRoute cmdlet deletes all of the routes on the server.

Parameters

-AddressFamily<AddressFamily[]>

Removes all of the routes that have a specific IP address family. The acceptable values for this parameter are:
-- IPv4: Removes all IP routes that have an IPv4 address.
-- IPv6: Removes all IP routes that have an IPv6 address.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-AsJob

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-AssociatedIPInterface<CimInstance>

Removes all of the IP routes that are associated with a specific network IP interface CIM object. This is typically as input through a pipeline.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

true (ByValue)

Accept Wildcard Characters?

false

-CimSession<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.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-DestinationPrefix<String[]>

Removes all of the IP routes that have a specific destination prefix. This parameter value contains an IP address prefix and a prefix length, separated by a slash (/). A destination prefix of 0.0.0.0/0 for IPv4 or ::/0 for IPv6 would indicate that the NextHop is a default gateway.

Aliases

none

Required?

false

Position?

1

Default Value

dhcp

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-InputObject<CimInstance[]>

Specifies the input to this cmdlet. You can use this parameter, or you can pipe the input to this cmdlet.

Aliases

none

Required?

true

Position?

named

Default Value

none

Accept Pipeline Input?

true (ByValue)

Accept Wildcard Characters?

false

-InterfaceAlias<String[]>

Removes all of the IP routes that are connected to a specific interface, described by the InterfaceAlias property.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

true (ByPropertyName)

Accept Wildcard Characters?

false

-InterfaceIndex<UInt32[]>

Removes all of the IP routes that are connected to a specific interface, described by InterfaceIndex number.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

true (ByPropertyName)

Accept Wildcard Characters?

false

-NextHop<String[]>

Removes all of the IP routes that have a specific next hop. This parameter value is the IP address of the next hop in the route. A next hop of 0.0.0.0 for IPv4 or :: for IPv6 would indicate that the route is on-link.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-PassThru

Returns an object representing the item with which you are working. By default, this cmdlet does not generate any output.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-PolicyStore<String>

Specifies the PolicyStore value. The acceptable values for this parameter are:
-- ActiveStore: The IP address information is currently valid.
-- PersistentStore: The IP address information is persistent across reboots. When the computer starts, the PersistentStore settings are copied to the ActiveStore.
The default value is ActiveStore.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-PreferredLifetime<TimeSpan[]>

Removes all of the IP routes that have a specific preferred lifetime. This parameter value uses time as defined by the TimeSpan structure.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Publish<Publish[]>

Removes all of the IP routes that have a specific publish setting. The acceptable values for this parameter are:
-- Age: The IP Route information is published and advertised in router advertisements with an finite ValidLifetime.
-- No: The IP Route information is published and advertised in router advertisements with an infinite ValidLifetime. This is the default.
-- Yes: The IP Route information is published and advertised in router advertisements with an infinite ValidLifetime.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-RouteMetric<UInt16[]>

Removes all of the IP routes that have a specific route metric. This parameter value specifies an integer cost metric for the route. This parameter value is added to the InterfaceMetric parameter value and the total value is used when choosing among multiple routes in the routing table that most closely match the destination address of a packet being forwarded. The route with the lowest, combined RouteMetric property and InterfaceMetric property value is chosen.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-ThrottleLimit<Int32>

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.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-ValidLifetime<TimeSpan[]>

Removes all of the IP routes that have a specific valid lifetime. This parameter value uses time as defined by the TimeSpan structure.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Confirm

Prompts you for confirmation before running the cmdlet.

Required?

false

Position?

named

Default Value

false

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Required?

false

Position?

named

Default Value

false

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

<CommonParameters>

This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, and -OutVariable. For more information, see    about_CommonParameters (https://go.microsoft.com/fwlink/p/?LinkID=113216).

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

  • Microsoft.Management.Infrastructure.CimInstance#rootStandardCimv2MSFT_NetRoute

    The Microsoft.Management.Infrastructure.CimInstance object is a wrapper class that displays Windows Management Instrumentation (WMI) objects. The path after the pound sign (#) provides the namespace and class name for the underlying WMI object.

Outputs

The output type is the type of the objects that the cmdlet emits.

  • None

Examples

EXAMPLE 1

This example removes all of the IP routes on the computer, including default routes.

PS C:\> Remove-NetRoute

EXAMPLE 2

This example removes all of the IP routes that have a next hop of 192.168.0.1.

PS C:\> Remove-NetRoute –NextHop 192.168.0.1

Get-NetRoute

New-NetRoute

Set-NetRoute