Solved

Powershell: Change metric on specific adapter

Posted on 2016-11-16
6
76 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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Create and license users in Office 365 in bulk based on a CSV file. A step-by-step guide with PowerShell script examples.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

785 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