The Get-VMSwitch
Hyper-V cmdlet returns VMSwitch objects which have a NetAdapterInterfaceDescription property but this is only populated for switches of type Physical.
For switches of type Internal this property is blank. The only obvious relationship between the virtual adapter on the host and the VMSwitch is the name - eg for switch "Foo" the default adapter name is "vEthernet (Foo)".
However, network adapters can be renamed. I've looked for other values on the output of Get-NetAdapter
that correlate with the switches but I haven't had any success.
Are there other cmdlets or APIs that can match an Internal Hyper-V Virtual Switch with a Host Network Adapter?
I stumbled upon the answer myself eventually. I can use:
This will return a
VMInternalNetworkAdapter
object with aDeviceId
property. I can then reliably get the correspondingMSFT_NetAdapter
object using: