Hi,
Following is the code I am using to retrieve information for network adapters attached to my virtual machine named 'XPSP3'
ManagementScope manScope = new ManagementScope(@"\\.\root\virtualization"); ObjectQuery queryObj = new ObjectQuery("SELECT * FROM Msvm_ComputerSystem WHERE ElementName='XPSP3'"); ManagementObjectSearcher manSearcher = new ManagementObjectSearcher(manScope, queryObj); ManagementObjectCollection manCollection = manSearcher.Get(); ManagementObject vm = null; foreach (ManagementObject o in manCollection) { vm = o; break; } ManagementObjectCollection ethernetPorts = vm.GetRelated("Msvm_SyntheticEthernetPort");
When the virtual machine is powered off 'ethernetPorts' collection is empty. And when it is running, 'ethernetPorts' contains the information about the netwrok adapters attached to the virtual machine.
How can I retrieve this information when the virtual machine is powered off?