Solved

Powershell: Change metric on specific adapter

Posted on 2016-11-16
6
57 Views
1 Endorsement
Last Modified: 2016-11-20
Recently Windows has taken away the adapter binding setting/GUI under network adapters -advanced -advanced settings (see image), they stated that nothing uses the adapter binding other than DNS, well I still need it for DNS, I’ve looked at a few PowerShell scripts that changes the Metric on an adapter to route DNS requests to one adapter first. These scripts work great, however the issue I have is I have no way to find the adapter automatically. I have to query each machine in order to place the metric on a particular adapter. I run the Get-NetAdapter On the target machine and the only thing in common on all the machines is the InterfaceDescription which was set when this adapter was installed. So the question I have is can I edit using PowerShell an adapters setting based upon the InterfaceDescription.
bring.PNG
So I have
Get-NetAdapter | where {$_.InterfaceDescription -eq “NeoRouter Virtual Network Interface”}
 But id like to cache the mac address of the neo router to  change its metric?
get-NetIPInterface doesn’t list mac address nor InterfaceDescription, so is there a way to match up get-NetIPInterface with Get-NetAdapter I tried using Get-WmiObject -Class Win32_NetworkAdapter.
I saw this script that does something similar
https://gallery.technet.microsoft.com/scriptcenter/Change-wired-network-db174767


Thanks in advance
1
Comment
Question by:Joe Danyi
  • 3
  • 2
6 Comments
 
LVL 83

Accepted Solution

by:
oBdA earned 500 total points
ID: 41891070
You can link them with the Interface index:
$NetIPInterface = Get-NetIPInterface -InterfaceIndex (Get-NetAdapter -InterfaceDescription 'NeoRouter Virtual Network Interface').ifIndex

Open in new window

2
 
LVL 1

Author Comment

by:Joe Danyi
ID: 41894883
Worked perfectly i did need to narrow down to just the IPV4 So i added
$NetIPInterface = Get-NetIPInterface -InterfaceIndex (Get-NetAdapter -InterfaceDescription 'NeoRouter Virtual Network Interface').ifIndex
$NETIPInterface2 = $NetIPInterface| Where-Object {$_.DHCP -like "disabled"}
$NETIPInterface2 | Set-NetIPInterface -InterfaceMetric 100

dumb followup question for the metric is it lowest number goes first or highest number goes first.
IE im trying to route DNS traffic though my NEO router so will 100 mean it will go to that adapter first or will 1 make it go though that adapter first?
0
 
LVL 83

Expert Comment

by:oBdA
ID: 41894898
Metric is the cost; lower numbers cost less and will be preferred. And "100" or "1" by itself doesn't mean much - the lowest number decides.
1
 
LVL 1

Author Comment

by:Joe Danyi
ID: 41894922
just to be sure,

if i have 5 adapters and the metrics of the adatper asending from 1 - 5. that would mean the adapters with the lowest cost IE adatper 1 would go first then adatper 2 and so on. as apose to it decending where 5 goes first then 4.

and i thank you for your time.
0
 
LVL 83

Expert Comment

by:oBdA
ID: 41894938
Yes.
1

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Utilizing an array to gracefully append to a list of EmailAddresses
I thought I'd write this up for anyone who has a request to create an anonymous whistle-blower-type submission form created using SharePoint 2010 (this would probably work the same for 2013). It's not 100% fool-proof but it's as close as you can get…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now