Debug Hyper-V VBSCript Samples

One of customers was not able to get the DNS name from a VM by running the samples at: https://msdn.microsoft.com/en-us/library/cc723870(VS.85).aspx

I debugged and found out that the Win2008 Virtual System was still running Hyper-V beta. Here are the steps that I took:

  1. Copied the VBScript from the MSDN website above.
  2. Saved the VBScript as GetVirtualSystemDNSName.vbs
  3. Ran following command: cscript /X GetVirtualSystemDNSName.vbs vmName
  4. Selected "New Instance of Visual Studio" as "Just in time debugger"
  5. Set break point at line 97 as shown in the picture below.

When I watched the values that was returned in the exchange items, the exchange item "Name" was "Fqdn". In the sample code, we tried to find Virtual System FullyQualifiedDomainName Kvp exchange item by running following XPath query:

xpath = "/INSTANCE/PROPERTY[@NAME='Name']/VALUE[child:text() = 'FullyQualifiedDomainName']"

The query returned empty node set sicne "Fqdn" != "FullyQualifiedDomainName".  

Fqdn was renamed to FullyQualifiedDomainName after Hyper-V beta.

In the debug watch window, there are other Kvp exchange items. By exploring the their contents from watch window, you will find that this sample code can be modified to retrive other Kvp items.

Cheers,

Howard.