Author Posts

August 19, 2017 at 3:11 am

How do you get a handle to the virtual network adapter on the host that is connected to a given internal VM switch? The only way I can figure out is to look for one named "vEthernet ($switchName)", but it's not very robust, as Hyper-V allows you to create switches with duplicate names, and I'm not sure if this naming scheme is consistent across versions. Hyper-V must keep a record of this somewhere as it will automatically remove the correct virtual net adapter when the VM switch is removed, but I wasn't able to find it after a fair bit of digging.

August 20, 2017 at 4:49 am

The answer is to look for it in VM network adapters instead of the host's network adapter list:

Get-VMNetworkAdapter -ManagementOS | where SwitchName -eq $switchName