New-NetRoute is a powerful Windows PowerShell command that can be used to create, modify, and delete network routes. It is an essential tool for network administrators who need to manage their network infrastructure. This guide will provide an overview of the New-NetRoute command, including its syntax, parameters, inputs, outputs, examples, and tips.

What is New-NetRoute?

New-NetRoute is a Windows PowerShell command that enables network administrators to create, modify, and delete network routes. It is part of the Windows Management Framework, which provides a set of tools for managing Windows-based networks. The New-NetRoute command is used to create, modify, and delete network routes, which are used to determine how traffic is routed across a network.

Syntax

The syntax for the New-NetRoute command is as follows:

New-NetRoute -DestinationPrefix -InterfaceIndex -NextHop [-AddressFamily ] [-Confirm] [-Force] [-PassThru] [-RouteMetric ] [-RoutePolicy ] [-RouteSource ] [-WhatIf]

Parameters

The New-NetRoute command has the following parameters:

  • DestinationPrefix – The destination prefix for the route.
  • InterfaceIndex – The interface index for the route.
  • NextHop – The next hop for the route.
  • AddressFamily – The address family for the route.
  • Confirm – Prompts for confirmation before executing the command.
  • Force – Forces the command to run without prompting for confirmation.
  • PassThru – Returns an object representing the created route.
  • RouteMetric – The route metric for the route.
  • RoutePolicy – The route policy for the route.
  • RouteSource – The route source for the route.
  • WhatIf – Displays what would happen if the command were to run.

Inputs

The New-NetRoute command requires the following inputs:

  • DestinationPrefix – The destination prefix for the route.
  • InterfaceIndex – The interface index for the route.
  • NextHop – The next hop for the route.

Outputs

The New-NetRoute command produces the following outputs:

  • Route – An object representing the created route.

Examples

The following examples demonstrate how to use the New-NetRoute command:

  • To create a route with a destination prefix of 10.0.0.0/24, an interface index of 12, and a next hop of 10.0.0.1, use the following command:

    New-NetRoute -DestinationPrefix 10.0.0.0/24 -InterfaceIndex 12 -NextHop 10.0.0.1

  • To create a route with a destination prefix of 10.0.0.0/24, an interface index of 12, a next hop of 10.0.0.1, and a route metric of 10, use the following command:

    New-NetRoute -DestinationPrefix 10.0.0.0/24 -InterfaceIndex 12 -NextHop 10.0.0.1 -RouteMetric 10

  • To delete a route with a destination prefix of 10.0.0.0/24, use the following command:

    New-NetRoute -DestinationPrefix 10.0.0.0/24 -Force

Tips

Here are some tips for using the New-NetRoute command:

  • Use the -Confirm parameter to prompt for confirmation before executing the command.
  • Use the -Force parameter to force the command to run without prompting for confirmation.
  • Use the -PassThru parameter to return an object representing the created route.
  • Use the -WhatIf parameter to display what would happen if the command were to run.

Conclusion

New-NetRoute is a powerful Windows PowerShell command that can be used to create, modify, and delete network routes. It is an essential tool for network administrators who need to manage their network infrastructure. This guide has provided an overview of the New-NetRoute command, including its syntax, parameters, inputs, outputs, examples, and tips.

Leave a Reply