3

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?

1
  • unfortuanetly I don't have 2k12 server in front of me but if I remember correctly there is a network index that you can use to create a relationshipt with, in other words its a relationship thats created by the output of two different cmdlets.
    – tony roth
    Jul 23, 2013 at 13:47

1 Answer 1

5

I stumbled upon the answer myself eventually. I can use:

$VMAdapter = Get-VMNetworkAdapter -ManagementOS -SwitchName Foo

This will return a VMInternalNetworkAdapter object with a DeviceId property. I can then reliably get the corresponding MSFT_NetAdapter object using:

Get-NetAdapter | Where-Object { $_.DeviceID -eq $VMAdapter.DeviceId }

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .