-- Ben Armstrong, Virtualization Program Manager
Talking about core virtualization at Microsoft (Hyper-V, Virtual PC and Virtual Server).
A little while ago David posted a really handy solution for evacuating a Hyper-V cluster node on shutdown automatically.
The issue that he is trying to address is that normally you should not just shutdown a node in a cluster, rather you should manually move all virtual machines off of the cluster node first. If you just shutdown a node in a cluster all the virtual machines will be failed over using quick migration.
David solved this problem by writing a PowerShell script that works with clustering to live migrate the virtual machines to another node in the cluster. He then uses group policy to get this script to be run automatically whenever a computer in his cluster is shutdown.
All-in-all it is a really cool solution to make your life a little easier. You can read all about it here:
http://pdconsec.net/blogs/davidr/archive/2010/09/01/Automatically-Live-Migrate-VMs-On-Host-Shutdown.aspx
Cheers, Ben
What happens when a shutdown force command is executed? ie: shutdown /f Does the script still run?
I would assume not - but I need to confirm that.
Yes, the shutdown script will still run if you force the host to reboot with shutdown /f - local policy and group policy shutdown scripts are executed during the shutdown sequence.
The original driver for the script was so that patching of the host servers with SCCM could occur automatically during maintenance windows; the reboots occur after patching is complete. There's one server per maintenance window - so at the end of the process, all servers have roughly the same number of VMs and one server is "empty". Then, SCOM/SCVMM Pro Tips take over and balance out anything grievously bad.
Thanks for the mention Ben :)
David -
Thanks for the extra info!
Cheers,
Ben
If you have a 2 node cluster, you get an error from trying to index an array when a single object is returned for available nodes. Casting the statement as an array fixes this:
$AvailNodes = @((get-clusternode | Where-Object { $_.State -eq "Up" -and $_.Name -ne "$Computer" }))