1

This Technet article explains how to create a static route for IPv4 in Microsoft's Routing and Remote Access with the MMC snap-in.

How can I script this, either through PowerShell or VBScript?

vcsjones
  • 722
  • 1
  • 8
  • 21

1 Answers1

2

The routes added via the mmc are simply added to the server routing table. So you can use a standard route add command inside a batch file

route add <address> <masK> <gateway> <metric> <interface>

However they won't show in the mmc if you add them this way, I'm not sure if that is a requirement from your question (Not enough rep to comment)

EDIT

netsh routing dump >> routes.txt  

Will dump the config for RRAS and you can add the following lines for each route.

add persistentroute dest=<IP> mask=<MASK> name="<Interface Name>" nhop=<Nexthop> proto=NONDOD metric=256 view=both
set persistentroute dest=<IP> mask=<MASK> name="<Interface Name>" nhop=<Nexthop> proto=NONDOD metric=256 view=both

Then Import using

netsh exec routes.txt >> import_log.txt
Drifter104
  • 3,773
  • 2
  • 25
  • 39