Month: April 2008

Enumerating Hyper-V virtual switches

Here is a script you can use to enumerate all the virtual switches you created using Hyper-V Virtual Network Manager. ‘Script Start Const wbemFlagReturnImmediately = &h10 Const wbemFlagForwardOnly = &h20 Set objWMIService = GetObject(“winmgmts:\\” & “.” & “\root\virtualization”) Set colItems = objWMIService.ExecQuery(“SELECT * FROM Msvm_VirtualSwitch”, “WQL”, _ wbemFlagReturnImmediately + wbemFlagForwardOnly) For Each objItem In colItems WScript.Echo “ElementName: ” & objItem.ElementName WScript.Echo “Name: ” & objItem.Name Next ‘Script End Name property gives the text you have provided during switch creation and ElementName is the GUID assigned to the virtual switch. There are many other properties most of which are default values. Msvm_VirtualSwitch class is neither documented on MSDN nor I could find anything on Google. I generally use PowerShell to understand WMI objects and methods/Properties provided by each of these objects. PowerShell revealed the Msvm_VirtualSwitch class and it’s properties. PowerShell’s Get-WMIObject command-let is an excellent tool to learn WMI interfaces. Here is how I found Msvm_VirtualSwitch class Get-WmiObject -namespace root\virtualization -list will list all the classes under root\virtualization name space. $VSwitch = get-wmiobject -namespace root\virtualization -class …

Using VMConnect.exe command line

Here is a post that describes how to use vmconnect.exe command line to open VM Console in a stand alone mode without using Hyper-V MMC snap-in. VMconnect.exe has the following command line parameters. ServerName, VMName and -G <GUID> parameters are self explanatory. However, -C <Count> parameter is very ambiguous. Help dialog specifies VM instance count but the actual meaning of the parameter is somewhat different. I had posted a question about this on the server virtualization technet forums and you can find a response to this from MS here. If it is not clear from the explanation MSFT provided, refer to the screen shot below. Using the -C parameter, you will need specify how many instances of VMConnect you are going to initiate. Based on the number you provide, VMConnect stacks the VM console windows in such a way that you could see all the VM names one above another. It just makes it easy to select a VM console window in a minimized state. Without this parameter, VM console windows will overlap each other …

Hyper-V Virtual Network settings in registry

Hyper-V, unlike Virtual Server R2, stores all virtual network information in the Windows Registry. Virtual Server R2 stores all this information in a .VNC file. As you create Virtual Switches and Adapters, it gets in to the windows registry at, HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\VMSMP Under this key, you can find Parameters\SwitchList which contains all Virtual Switches and Parameters\NicList which contains all virtual adapter information on the parent partition Under each virtual switch entry, you can find references to all virtual adapters in guest as well as parent partition

I am back…

It is just 10 days since last post but seems like many days..! I have been busy with some new assignments at work and naturally that one is getting more priority. I have not really worked on Hyper-V in last couple of weeks. I will soon (re)start my research on various aspects on this new technology Here is a list of topics you will soon find on my blog. I am working on all of these as I write this post. Hyper-V VM Switch Configurations VLAN Configuration & Gotchas Some more WMI scripts to manage various parts of Hyper-V Some more scripts to demonstrate the power of regular expressions and …. many more Stay tuned..!