Virtualization automation with Hyper-V: Windows PowerShell scripting

With Microsoft Hyper-V, your greatest virtualization automation weapon is Windows PowerShell scripting. You can use cmdlets and task scheduling to improve task automation.

Virtualization automation in a Microsoft Hyper-V infrastructure takes on a somewhat different form than VMware....

That’s because Microsoft has an important virtualization automation tool at its disposal: Windows PowerShell scripting, which administrators can use in VMware infrastructures with vSphere PowerCLI.

In addition, Microsoft’s System Center Virtual Machine Manager (SCVMM) Self-Service Portal provides chargeback, and Microsoft has moved further into the cloud market with AppController (formerly Project Concero), although that product doesn’t quite fit the cloud automation bill yet.

With Windows PowerShell scripting and other task automation options, you can automate virtual machine (VM) creation, host assignment and more in Microsoft Hyper-V. There’s even a task scheduler where you can view your virtualization automation tasks and monitor the results.

This section of our guide on task automation and workflow orchestration explains how to use Windows PowerShell scripting and other tools to automate a Microsoft Hyper-V infrastructure.

Weighing Hyper-V R2 task automation options

Hyper-V comes with built-in task automation for simple VM activities such as powering on a machine, but it doesn’t come with well-formed cmdlets. Hyper-V R2, however, uses SCVMM to execute more streamlined commands. SCVMM comes with simpler cmdlets, which you can run on servers that have SCVMM installed rather than having Hyper-V execute the command itself. You’ll also find simple task automation commands in the PowerShell Management Library, an open source project that provides a freeware alternative to SCVMM’s PowerShell cmdlet set.

Using Windows PowerShell scripting for task automation

You can use the Windows Task Scheduler to schedule automated tasks in Hyper-V. Once you enter any script into the Task Scheduler, you can view all your scheduled tasks, check their last run time, and see if there were any execution errors in the Windows PowerShell scripting console. Task automation is a great way to convert physical machines into VMs, create highly available VMs and find the most suitable host.

Hyper-V management with PowerShell: Monitoring and testing

If you run Windows Server 2008 R2, you can use a freeware library of PowerShell cmdlets -- called the PowerShell Module for Hyper-V -- to monitor and manage the virtualization platform. With this Windows PowerShell scripting module, you can automatically retrieve information on VM states, hardware configurations, VM health, memory capacity and functionality. Automated PowerShell monitoring means you’ll always have the most updated information about your infrastructure.

Using SCVMM Self-Service Portal 2.0 to manage chargeback

For automatic billing, many organizations are turning to chargeback tools such as VKernel’s vOPS Reporting and Chargeback and Quest Software’s vFoglight, which includes a chargeback feature. Microsoft’s Self-Service Portal 2.0 can manage resources, track usage and ensure that users pay for their appropriate resources. These virtualization automation tools can take a lot of manual resource tracking off the hands of administrators.

Is initial placement in Hyper-V like Distributed Resource Scheduler?

When it comes to task automation features, Microsoft Hyper-V doesn’t always hit the mark. Compared to VMware’s Distributed Resource Scheduler, Microsoft’s initial placement feature for new VMs lacks full automation. Once Microsoft selects the best host for the VM, it stays there and can’t live migrate anywhere else. VMware DRS, on the other hand, offers three levels of virtualization automation and can even automatically restore VMs to their original host when they come back online after a failure.

Cloud automation with Microsoft Concero and vCloud Director

Automation is critical for a cloud deployment, but it’s not always guaranteed. VMware vCloud Director offers cloud automation through VM provisioning, resource allocation, and a new vCenter Orchestrator plug-in, but Microsoft Concero (now called AppController) lacks some of those cloud automation requirements. Microsoft’s cloud management tool currently has no chargeback or showback system, and its service templates reside in SCVMM, so admins need access to the virtualization layer to execute tasks.

Task automation and orchestration: Table of contents

  • task automation and workflow orchestration with virtualization
  • IT process automation and performance monitoring
  • VMware automation: Site Recovery Manager, vSphere PowerCLI
  • Virtualization automation with Hyper-V: PowerShell scripting

Dig Deeper on Microsoft Hyper-V management