Link to home
Start Free TrialLog in
Avatar of Adam Flook
Adam FlookFlag for United Kingdom of Great Britain and Northern Ireland

asked on

powershell interfaceindex new-netroute

Powershell to check -interfaceindex number put it into a variable then use the variable to apply static routes with new-netroute.

i have been looking at get-netipinterface and can display the info i need in the ifindex column i am however unsure how to get it into a variable and then use that to apply the static route.

with something like this New-NetRoute -DestinationPrefix "10.0.0.0/24" -InterfaceIndex "variable" -NextHop 192.168.0.1

PS C:\Users\Adam> Get-NetIPInterface "work"


ifIndex InterfaceAlias                  AddressFamily NlMtu(Bytes) InterfaceMetric Dhcp     ConnectionState PolicyStore
------- --------------                  ------------- ------------ --------------- ----     --------------- -----------
47      Work                            IPv4                  1400              35 Disabled Connected       ActiveStore
ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Adam Flook

ASKER

Hi exactly like that thanks
works exactly as needed