Modify NIC bind order for Hyper-V Server/Server Core

hyper-vnicwindows-registrywindows-server-core

Is there a way to modify the NIC bind order in Hyper-V Server/Server Core? For some reason, one of our Hyper-V servers decided to reverse the bind order of two of the six NIC ports on the machine, making it inconsistent with all of our other servers (not to mention being out of sequence with the phyical layout of the NICs).

I know this can be done via a network settings GUI in the full server installation, but alas, said GUI does not exist in Server Core. I believe that this will require a direct registry edit, but I am not sure where.

Any help would be appreciated.

Best Answer

I looked this up because I could really use that. If you are running Core, you probably do not want or have the authority to install extra software, even if it is a CodePlex dig (I have a lot more respect for that than straight up Microsoft garbage). You can do it programmatically with WMI

==== snip - Start of script code Set_Wireless_NIC_IPMetric.vbs script ====
On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

regValueDataMetric = "35"

Set colItems = objWMIService.ExecQuery _
("Select * From Win32_NetworkAdapter Where NetConnectionID = 'Wireless Network Connection'")

For Each objItem in colItems
strMACAddress = objItem.MACAddress
Wscript.Echo "MACAddress: " & strMACAddress
Next

Set colNetCard = objWMIService.ExecQuery _
("Select * From Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")

For Each objNetCard in colNetCard
If objNetCard.MACAddress = strMACAddress Then
For Each strIPAddress in objNetCard.IPAddress
Wscript.Echo "Description: " & objNetCard.Description
Wscript.Echo "IP Address: " & strIPAddress
Wscript.Echo "IPConnectionMetric: " & objNetCard.IPConnectionMetric
objNetCard.SetIPConnectionMetric(regValueDataMetric)
Next
End If
Next
==== snip - End of VBS script ====

Or, do a one-off from WMIC when you figure out the MAC address or unique identifier of the NIC in question.

# Find the NIC you want.
wmic nicconfig where "ipenabled='true'" get caption, macaddress

# Set it on the NIC of choice.
wmic nicconfig where "ipenabled='true' and macaddress='00:00:00:00:00:AA'" call setipconnectionmetric(METRICYOUWANT)

It returns 0, but I cannot figure out why it does not come up. Maybe you need to reset the NIC.

Related Topic