Solved

Powershell: Change metric on specific adapter

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

Accepted Solution

by:
oBdA earned 500 total points
Comment Utility
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
 

Author Comment

by:Joe Danyi
Comment Utility
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 82

Expert Comment

by:oBdA
Comment Utility
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
 

Author Comment

by:Joe Danyi
Comment Utility
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 82

Expert Comment

by:oBdA
Comment Utility
Yes.
1

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

772 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

15 Experts available now in Live!

Get 1:1 Help Now