Solved

Powershell: Change metric on specific adapter

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

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 84

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 84

Expert Comment

by:oBdA
ID: 41894938
Yes.
1

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

The following article is intended as a guide to using PowerShell as a more versatile and reliable form of application detection in SCCM.
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

749 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