There haven’t been any new blogs on Hyper-V.nu in the past weeks because of …. you know … an absolute dearth of time. It so happened that my other Hyper-V.nu colleagues had the same luxury problem in these economical challenging times.

So while I was doing a lot of other things which I will soon be able to talk about, I asked my colleague Sander Klaassen to fill in the gap and write a guest blog. Sander is also a Microsoft virtualization enthusiast and combines this with his broad other expertise.

Please welcome our guest blogger Sander Klaassen!

____________________________________________________________________________________________________________________________________________

Over de last years I developed a script to quickly scan a customer’s IT environment. Recently I added a Hyper-V module which collects data from Hyper-V hosts and VM’s. I showed Hans Vredevoort the output and he asked me to write a blog about it. I was not sure to share the code, because it isn’t very clean, since I only occasionally work on it.

I created a VBScript and not a PowerShell script because I wanted to be able to run it without installing anything, and VBScript is part of windows since Windows 2000 so it’s always available. 

This is also the reason why I made this script besides the regular Microsoft scan tools like ACT and MAP. They all need installation of components or even agents.

I modified the script for this blog, I changed the script by requesting input in a text file instead of Active Directory. This text file is a simple list of machine names:

  • HyperV01
  • HyperV02
  • HyperV03

Save it in the same directory as the VBScript with the name “machinelist.txt

The script queries WMI name spaces of each machine and when it finds the Hyper-V role, it collects the following information:

image

The VMMemDemand value was particular challenging; I couldn’t find the value anywhere in WMI, so I asked Hans if he knew, he forwarded the question to his fellow MVP’s and he got an answer. No wonder it was difficult to find. Turned out it is calculated from 2 values in a WMI property that contains an array filled with XML blobs.

The script makes a CSV output file in the directory of the script, using semicolon (;) as the separator character. This script should be run with elevated rights. (Otherwise, the cluster information is not complete)

The output is optimized for pivot table use in Excel. So with pivot tables the collected information can be formed to actually say something.

clip_image001

JSNVI01 and JSNVI02 are two hyper-V hosts in a cluster, each with 8 physical cores. First node has 8 virtual cores while the second node has 15 virtual cores active. Same goes for memory.

With a slightly more complex pivot table you can find SP1 VM’s with a lower memory demand then the VMMemMin value.

This means the VM uses less memory then the minimal configured amount, so the minimal memory value can be lowered to save some more memory.

I still have plenty idea’s to add or change the script like getting more VM configuration information while the VM is switched off.

Download script SummarizeHyperV

image

You can execute this script by the following command:

cscript.exe .\SummarizeHyperV.vbs

Don’t forget to create the textfile with your own Hyper-V hosts in it!