Hyper-V v3, PowerShell, Scripting, Virtualization
comments 3

Get Hyper-V (Windows Server 2012) guest network configuration using WMI

If you have not seen this yet, the updated WMI namespace for Hyper-V role in Windows Server 2012 has some hidden gems. I love playing around with WMI and the changes in Hyper-V namespace had me thinking about new possibilities.

Here is the first one in this series of posts on how you can extend Hyper-V management beyond what is available in the Hyper-V PowerShell module.

In this post, I will show you a simple function to get the guest network configuration details using WMI. We use the Msvm_GuestNetworkAdapterConfiguration WMI class to achieve this.

In the above function, we are making use of the updated virtualization namespace root\virtualization\v2.

In this function, we first get the virtual machine object:

Once we have the VM object, we retrieve the VM setting data which includes information on how many synthetic network adapters are attached, etc.

Since the above command gives us entire VM setting data and we are interested only in the synthetic adapter data, we filter this further to get only the synthetic adapters attached to the VM:

This is it. Finally, we retrieve the guest network configuration data associated with each of the network adapters.

Here is how we can use this function:

or

Filed under: Hyper-V v3, PowerShell, Scripting, Virtualization

by

Ravikanth is a principal engineer and the lead architect for Microsoft and VMware virtualized and hybrid cloud solutions within the Infrastructure Solutions Group at Dell EMC. He is a multi-year recipient of Microsoft Most Valuable Professional (MVP) award in Windows PowerShell (CDM) and Microsoft Azure. Ravikanth is the author of Windows PowerShell Desired State Configuration Revealed (Apress) and leads Bangalore PowerShell and Bangalore IT Pro user groups. He can be seen speaking regularly at local user group events and conferences in India and abroad.