Hyper-V host virtual net adapter

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.

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