Managing the Hyper-V Default Switch in Windows 10 version 1709 and higher with PowerShell

Windows 10 version 1709 introduced a default Hyper-V virtual switch which is installed when the Hyper-V role is added. As you can see in the following example, by default on Windows 10, the default virtual switch does not exist because the Hyper-V role hasn't been added.



Now that the Hyper-V role has been added, you can see that a new network adapter named "vEthernet (Default Switch)" exists.

1Get-NetAdapter | Format-Table -AutoSize


While you wouldn't think this would be a problem, I've seen some latency problems on the host operating system once this default switch is added. The problem seems to be related to the interface metric being the same on the physical network adapter and the default switch.



While you would think the default route would take precedence, something just doesn't seem right. Having the metric set exactly the same by default doesn't seem like a good idea.

1Get-NetRoute | Format-Table -AutoSize


Maybe you're like me and think that disabling the default switch would be the way to resolve this problem? Bad idea. Trust me, learn from the mistakes of others.

1Disable-NetAdapter -Name 'vEthernet (Default Switch)' -PassThru -Confirm:$false


Everything seems to work fine after disabling it, but wait.



Guess what happens after you reboot? The disabled network adapter goes into a "Not Present" state and a new default switch is created which is enabled.



I received a response from one of the program managers of the Hyper-V team about this issue on Twitter last year and provided them with the information they requested.

Now you not only have a latency problem, but you also have the problem of getting rid of a network adapter that's not present. Unfortunately, there doesn't seem to be a PowerShell command for removing a network adapter. Maybe like me, you decide to resort to some arcane DOS command to nuke all of your network settings.

1netcfg.exe -d


That would also be a bad idea as you'll end up with another default switch and this time, one of them is in limbo.



I had to resort to using the GUI to remove these network adapters.


After removing them and rebooting, I was back to square one.



The solution seems to be to change the metric on the default switch so the host OS prefers the physical adapter.

1Get-NetIPInterface -InterfaceAlias 'vEthernet (Default Switch)'
2Get-NetIPInterface -InterfaceAlias 'vEthernet (Default Switch)' | Set-NetIPInterface -InterfaceMetric 5000 -PassThru


This seems to be a hot mess as you'd think Microsoft would prevent disabling the default switch if it causes problems, otherwise you can end up with numerous copies of it and that can't be good.



I built a Windows 10 version 1809 VM and enabled Hyper-V on it. The metric for its default switch was already set to 5000, so this problem may be resolved with newer fresh installations of Windows 10. It is not however resolved for Windows 10 installations that are updated from previous versions to version 1809.