Reputation: 91895
I've got a Hyper-V host, with several guests, each with one or more network adapters. How do I enumerate the network adapters on those guests?
Specifically, I'm looking for a particular guest, given a MAC address.
I'm using C# and System.Management
.
Upvotes: 2
Views: 2194
Reputation: 91895
I'll leave out some of the details:
SELECT * FROM Msvm_ComputerSystem
).Msvm_SyntheticEthernetPort
objects.var ports = computerSystem.GetRelated("Msvm_SyntheticEthernetPort"); foreach (ManagementObject port in ports) {
var portSettings = port.GetRelated("Msvm_SyntheticEthernetPortSettingData"); foreach (ManagmentObject portSetting in portSettings) {
string macAddress = (string)portSetting .GetPropertyValue("Address");
Upvotes: 2