Problem solve Get help with specific problems with your technologies, process and projects.

Weighing Hyper-V R2 task automation options

Hyper-V R2's built-in task automation suffices for simple tasks, but more complex ones require alternative tools. Here's how to educate customers on their options.

Solutions provider takeaway: Hyper-V R2's built-in task automation may suffice for simple tasks, but it's too limited for more complex ones. Solutions providers should help customers evaluate Hyper-V task management options -- from System Center Virtual Machine Manager to freeware alternatives -- and educate customers on each option's pricing and support-level tradeoffs.

Microsoft Hyper-V R2 can be a smart move for a cash-strapped customer that wants to virtualize its environment. But as you may know, free technologies come with limitations.

More on Hyper-V R2

Third-party tools for Microsoft Hyper-V R2: Top 5 must-haves

Most useful Windows Server 2008 R2 and Hyper-V R2 features

Three setbacks when designing Hyper-V R2 High Availability

Hyper-V R2 features: Top 10 resources

Hyper-V's built-in task automation is a perfect example. Solutions providers can manage Hyper-V R2 alone in Windows Server 2008 R2 with the PowerShell command line. But Hyper-V's singular PowerShell capabilities are complex at best and limiting at worst.

PowerShell is designed as a command-line solution in which well-formed cmdlets can automate simple tasks. A well-formed cmdlet can power on a virtual machine with a few keywords on a single line. But Hyper-V doesn't come with a set of well-formed cmdlets out of the box, so task automation in Windows Server 2008 R2 is limited. Instead, Hyper-V's native PowerShell leans on Windows Management Instrumentation (WMI) to get the job done.

So, while solutions providers can use WMI to automate the types of virtual machine (VM) tasks that customers want, using WMI for what should be a single-line command for a simple task requires extra effort.

As customer, for example, that is familiar with PowerShell might expect a single cmdlet for listing the checkpoints (also called "snapshots") that are attached to every VM on the Hyper-V host. Such a command might look like the following:

Get-VMCheckpoint –VMMServer

This isn't as simple as it looks, though, because the command doesn't work with Hyper-V alone. Getting this information out of Hyper-V requires you to type a variation of this command:

$VM = Get-WmiObject -Namespace root\virtualization -Query "Select * From Msvm_ComputerSystem Where ElementName='VmToSnapshot'"

Get-WmiObject -Namespace root\virtualization -Query "Associators Of {$VM} Where AssocClass=Msvm_ElementSettingData ResultClass=Msvm_VirtualSystemSettingData" | Format-List -Property ElementName, InstanceID

The complicated nature of the second command prompts many Windows administrators steering clear of PowerShell command line task automation for Hyper-V.

Simplifying task automation in Hyper-V R2

Solutions providers have a few options to make Hyper-V commands less complex. System Center Virtual Machine Manager (SCVMM) is intended to be the management layer for Hyper-V and is an absolute must for environments where customers have many Hyper-V hosts that operate together. SCVMM provides the simple cmdlets that Hyper-V lacks on its own.

You can run the first command above on a server where SCVMM is installed or from a desktop computer where the SCVMM administrative tools have been installed. Running the first command there will produce the desired result because Hyper-V is no longer acting singularly.

While Hyper-V involves no extra cost above and beyond the Windows Server 2008 R2 license, you should make customers aware that SCVMM requires additional licensing. Even with the added cost, SCVMM's command line automation and other features makes it an easy sell when developing specifications for customers.

Customers that don't want the added cost of SCVMM have other options. The PowerShell Management Library for Hyper-V is an open source project by Microsoft's James O'Neill and a freeware alternative to SCVMM's PowerShell cmdlet set. Keep in mind that because it is open source, it doesn't come with the same levels of support available from SCVMM. But installing its PowerShell module to an available Hyper-V machine or desktop computer provides a combination of 31 different verbs and 69 nouns for streamlining command line automation.

In some cases, cmdlets in the PowerShell Management Library for Hyper-V can provide greater functionality than does SCVMM. Snapshots, for example, can be viewed and manipulated by using at least eight different cmdlets in the library. These eight cmdlets perform the following functions:

  • Get-VMsnapshot: Returns snapshots for one or more VM(s).
  • Get-VMsnapshottree: Displays all the snapshots of a VM in a tree view.
  • Select-VMsnapshot: Allows the user to select a snapshot for a VM.
  • New-VMsnapshot: Creates a new snapshot of one more VMs.
  • Rename-VMsnapshot: Changes the display name of a snapshot.
  • Update-VMSnapshot: Replaces an existing snapshot with a new one.
  • Restore-VMsnapshot: Rolls a VM back (or forward) to a snapshot.
  • Remove-VMSnapshot: Removes one or more snapshots from a VM.

For solutions providers that deal with multiple Hyper-V tasks -- particularly for customers with large environments -- task automation is a necessity. Ensuring that customers have the proper management capabilities at their fingertips is an important step as you guide customers through a Hyper-V purchase.

About the author
Greg Shields, MVP, vExpert, is a partner with Concentrated Technology. Get more of Greg's tips and tricks at

Dig Deeper on Server virtualization technology and services

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.