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.

Get-NetAdapter

hyperv-defaultswitch1a.jpg

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

Get-NetAdapter | Format-Table -AutoSize

hyperv-defaultswitch2a.jpg

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.

Get-NetIPInterface

hyperv-defaultswitch3a.jpg

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.

Get-NetRoute | Format-Table -AutoSize

hyperv-defaultswitch4b.jpg

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.

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

hyperv-defaultswitch5a.jpg

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

Get-NetAdapter

hyperv-defaultswitch6a.jpg

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.

Get-NetAdapter

hyperv-defaultswitch7a.jpg

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.

netcfg.exe -d

hyperv-defaultswitch8b.jpg

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.

Get-NetAdapter

hyperv-defaultswitch9a.jpg

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

hyperv-defaultswitch10a.jpg

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

Get-NetAdapter

hyperv-defaultswitch11a.jpg

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

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

hyperv-defaultswitch13a.jpg

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.

Get-NetAdapter

hyperv-defaultswitch14a.jpg

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.

ยต