In my post last week, I highlighted a number of ways to harness the power of virtualization with little or no costs. One tool I mentioned was the open source PowerShell Hyper-V Management library written by James O’Neill available on CodePlex. This library of PowerShell commandlets can enable you to automate and monitor all sorts of Hyper-V related tasks. I install and use the library on all of my Hyper-V hosts because it provides me with a simple, consistent command line user interface to access and report on my virtual environment. There is some documentation available on how to load and use the library online, but I go into more detail in two chapters of our book about Hyper-V. We’re revising the book right now to cover enhancements in Windows Server 2008 R2 – one of which is the inclusion of PowerShell V2. The new version of PowerShell includes some cool enhancements you may not know about, like Out-GridView. I use it with the Hyper-V library to filterable / sortable reports of my virtual environment. Here are a few quick examples.
Data gathering across multiple physical systems can be hard, and sometimes the best way to collect information seems like laborious “cut and paste” torture. How might you (for example) gather all the MAC addresses from your VM’s virtual network cards for a network audit? You could access the setting for each VM using Hyper-V Manager one at a time… but there’s an easier way! I can generate a report of all the MAC addresses for virtual machine in my environment by creating a list of my Hyper-V hosts (in a text file called Serverlist.txt) and typing the following command line:
get-vmnic -server (get-content .\serverlist.txt) | select * | out-gridview
Being able to create reports like this on the fly is super useful, and I can’t imagine how I would be able to gather information as easily with out the library (other than using System Center Virtual Machine Manager!).
The truth is, I’m not a scripting or a PowerShell expert. I don’t use it every day and often forget how to use the library. I’ve used Out-Gridview to create a report of all the functions in the library that I keep in Excel using the following command line:
get-command -module HyperV | get-help | select-object -property name, synopsis | out-gridview
I perform all sorts of management task too, like creating new VMs or starting /saving the state of all VMs on a host – those things are a piece of cake to automate. One super useful thing I do with the library is to Live Migrate all the VMs from cluster node to another with one simple command line. Say for example I wanted to move all the VMs from one node (HPDL380T) to another (HPDL380B), I could just use the following:
Get-VM -server HPDL380T | move-vm -Destination HPDL380B
These are just a few examples of how I use the library (lots more in the update to our book!). If you would like to see examples of other ways to automate tasks with the library, leave me a comment. For other great ideas on automation, checkout the TechNet Script Center. It’s packed full of scripting examples, tutorials, witty repartee – all at the same low low price!
Mike Sterling and I have been hiding this winter and updating everyone’s favorite Hyper-V book to include Windows Server 2008 R2 (we’ll at least it’s our favorite Hyper-V book!).
We just got a shot of the cover (below). It should be available by TechEd 2010 (I’m there), but feel free to pre-order a few zillion copies if you like.
There’s been recent press about customers deploying multiple virtualization technologies in production to control costs. Let’s face it, VMware with all it’s bells and whistles (you may not even use) is expensive. Hyper-V is priced right, runs wicked fast, and comes with Windows Server 2008.
So with all of that, why not check out Hyper-V? Perhaps you’re a shy VMware admin that doesn’t want to admit you don’t know a lot about Hyper-V?
(is that how you spell that?).
Nick Smith has a TechNet web cast JUST FOR YOU, Mr.VMware GUY! (or gal)
It’s titled “Hyper-V for the VMware Administrator,” and it’s NEXT WEEK!
Monday, March 1st, at 11:00AM Pacific (that’s 2:00PM Eastern). Be sure to register using the following link:
Nick is a very practical (and fast talking) virtualization expert with lots of experience working in real world environments. It should be a great session, even if you’re not a VMware user – touching on performance and resource optimization and much more.