blog.powershell.no

On Windows PowerShell and other admin-related topics

System Center Virtual Machine Manager vCheck

System Center Center Virtual Machine Manager (SC VMM) is part of the Microsoft System Center family, used to manage virtual infrastructures. The 2008 R2 version supports managing both Microsoft Hyper-V and VMware (communicating via VMware vCenter), while the 2012 version which was released in April 2012 added support for Citrix XenServer. Among the added benefits of using SC VMM for managing your hypervisor infrastructure is capabilities such as Physical to Virtual (P2V) conversion, creating virtual machines based on templates as well as having a centralized console for management. The 2012 release also added capabilities for managing private cloud infrastructures, where the managed hypervisors will be abstracted under the new Fabric bar:

image

There are many additional changes in the 2012 release, including the ability to manage services, storage, networking, cluster creation and many more. If you are interested in learning more I would recommend you to watch the TechNet Edge video Virtual Machine Manager 2012: Technical Overview as well as dig into the product documentation (link in the Resource section below).

Most, if not all, Hyper-V production environments I have worked with use SC VMM for management. One thing that many administrators may miss however, is a quick glance at the status of the environment. You do of course see the status of the hosts and virtual machines by opening the console, but other things such as old checkpoints and the use of dynamic virtual hard disks instead of Fixed size virtual hard disks is not easily discoverable. Since SC VMM is based on Windows PowerShell (for example, you get a “View Script” button showing the complete PowerShell code when creating a new virtual machine), gathering this information and presenting it in a report is not so difficult. Let me introduce the SC VMM vCheck:

 

SC VMM vCheck

If you work with both PowerShell and VMware, there is a good chance you have seen and used Alan Renouf`s very useful vCheck script:

vCheck is a vCenter checking script, the script is designed to run as a scheduled task before you get into the office to present you with key information via an email directly to your inbox in a nice easily readable format.

For more information and detailed usage guidance, see this article.

Beginning with the 6.0 release of vCheck, Alan added the support for Plugins, making it easier for the community to contribute with their own checks. I had several snippets of PowerShell code for checking various things such as VMs with snapshots, so when I saw the new Plugins capability added to vCheck I thought it would be a good opportunity to provide a SC VMM Plugin. Here is the initial checks in the SC VMM Plugin for vCheck:

  • SC VMM Connection Plugin
  • General Information
  • SC VMM Basic Host Information
  • Hyper-V Cluster Shared Volumes
  • Hyper-V VMs with snapshots
  • SC VMM New VMs
  • SC VMM VM Operating System Statistics
  • Hyper-V VMs with mounted ISO
  • Hyper-V Legacy VM NIC Adapters
  • Hyper-V VMs with static MAC address
  • SC VMM Dynamically Expanding Disks
  • SC VMM Dynamically Expanding Disks Consolidation Forecast
  • Hyper-V Integration Components Version
  • Hyper-V 2008 R2 SP1 Capacity Report

As you can see I have divided the plugins into two categories, one for SC VMM which works across all supported hypervisors, as well as some specific for Hyper-V.

vCheck contains a ps1-file named GlobalSettings.ps1, where you can specify the name of the SC VMM server, e-mail settings (if you want the report e-mailed to you) as well as HTML color codes. Here you can see two examples of the same report using different colors:

image  image

You can download the plugin from this link:

SC VMM vCheck Plugin Download

If you want to add a new Plugin, all you need to do is to create a ps1-file in the Plugins-folder, preferably in a subfolder. Then you add the following 7 variables at the top of the file, and your code at the bottom. The main script will pick up objects from the Plugins, so make sure you output objects with only the desired properties. For example Get-VM | Select-Object name.

We can look at the VM Operating System Statistics as an example:

$Title = "VM Operating System Statistics"
$Header ="VM Operating System Statistics"
$Comments = "VM Operating System Statistics"
$Display = "Table"
$Author = "Jan Egil Ring"
$PluginVersion = 1.0
$PluginCategory = "SC VMM"

# Start of Settings
# End of Settings

$VMs | Group-Object operatingsystem | Select-Object name,count | Sort-Object count -Descending

This is actually a PowerShell “one-liner” turned into a vCheck Plugin. Note that the $VMs variable contains all virtual machines managed by SC VMM and is created in the SC VMM Connectivity Plugin. The settings section is not used by the above plugin, however, this is a section intended for Plugin specific settings such as the threshold for how old snapshots you want to include in the report.

Over time the SC VMM Plugin will hopefully grow by added community contributions. If you want to contribute, or have suggestions for new Plugins, please add them to the SC VMM Plugin site`s comment section, as more people will discover them there compared to this article.

If you want to hear more about the SC VMM vCheck I was interviewed to talk about it on the Get-Scripting podcast, you can download the episode from here.

 

Resources

System Center Virtual Machine Manager 2012 on Microsoft TechNet

System Center Virtual Machine Manager 2008 and 2008 R2 on Microsoft TechNet

Automate a task in System Center Virtual Machine Manager 2012 based on the “View Script” button

May 31, 2012 Posted by | Hyper-V, System Center, Windows PowerShell | | Leave a comment