Adam Flook
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
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
works exactly as needed
ASKER