PowerShell Scripts In Hyper-V

Virtual Machine Command Line Prompts - Integration Service Version and State

Aug 1, 2013 by Jason Powell

Hyper-V 2012 is great and completely viable for production environments. However, there are bits of information that aren’t easily obtainable from the graphical user interface (GUI) and it is a tedious, manual process to find them.

The answer to this is PowerShell. With PowerShell you can grab the data you’re seeking (that may or may not be obtainable from the GUI at all) and output that into a usable file for reporting. The end goal here is to compile a larger script that contains all of these items and much more to give a one-stop report that we can use to assess the health/configuration of a Hyper-V environment in the future.

The following script, originally found on Benjamin Armstrong’s blog, polls the Hyper-V host for the version of Integration Services that the host is. Then, it takes and polls the version of Integration Services running on each of the virtual machines (VMs) on that host and does a check against the version of the host.

It outputs options that tell you the VMs are running “up to date”, “version mismatch”, or “unknown” (which means they aren’t installed). If you are not using system center virtual machine manager (SCVMM) there isn’t really an easy way to check, hence the use for this script:

Sample output:

1

The second was written by me and is just a way to poll all of the VMs on a particular host, and list in a table what virtual network they are using, what their IP address(s) is/are, and their MAC addresses. If you wanted to check all of this info, you would have to go to each individual VM, pull up the settings, and look. This is much more efficient and can be output to a CSV file, as opposed to me checking and making entries one by one.

Sample output:

 2

The last script was written by another Mirazon engineer, Brent Earls. This script’s function is to poll information on the LUNs or vDisks being presented from the SAN to a Hyper-V host. In VMware it is built into the GUI to be able to check your paths to your storage system.

When LUNs are presented from the SAN you typically want to use a policy/method called MPIO (stands for Multi Path I/O). This means you should have a least two paths (dependent on your environment) for each disk. That way if a path fails, the hypervisor should failover to use the other path.

In Hyper-V this is not so easy to obtain without digging through the disk management and manually checking one by one, with many LUNs presented this can be super tedious, so Brent came up with this. From running the script you can see below, it’s easy for us to glance and make sure that all disks are being present with the appropriate number of paths, if any showed only one path, we would know we have something going on in our environment.

Sample output:

3

Adopting Hyper-V might be a great option for your business. Call us at 877.552.0404 to learn more!

Press enter to search