Technology Toolbox

Your technology Sherpa for the Microsoft platform

Jeremy Jameson - Founder and Principal



Starting and Stopping Hyper-V VMs with Server Core

This post originally appeared on my MSDN blog:

Since I no longer work for Microsoft, I have copied it here in case that blog ever goes away.

Last week before heading out to the airport for my SharePoint 2010 training, I powered down the "Jameson Datacenter" (i.e. the four computers running in my home office). Since I would be gone for almost 8 full days, it didn't make sense to waste the electricity just so my SQL Server could periodically send email messages to me about backups being completed successfully throughout the day. [Note that my wife uses only the Media Center in the family room and her laptop to fulfill all of her computing needs (primarily sending and receiving email, as well as surfing Facebook) and my daughter is too young to use any computer by herself.]

The day after I got back from Redmond, I powered up the servers, but then realized that this was the first time that I had explicitly shutdown both Hyper-V VMs that serve as domain controllers (i.e. XAVIER1 and XAVIER2, that I referred to in a previous post). Note that I had since moved one of the domain controller VMs to a different Hyper-V server. In other words, two of the four computers in my home office (ROGUE and ICEMAN) run Windows Server 2008 x64 Server Core, and each server hosts a DC so that I have some degree of fault tolerance.

When I attempted to start the VMs using Hyper-V Manager from my Windows 7 desktop, I encountered the following error shortly after seeing the "Connecting to Virtual Machine Management service..." message:

Cannot connect to the RPC service on computer 'ICEMAN'. Make sure your RPC service is running.

Well, the RPC service was definitely running, but since both DCs were powered down, Hyper-V Manager had no way of authenticating me in order to access the remote servers (note that I got the same error message when trying to access ROGUE).

I could login to both Hyper-V servers (with my domain account, thanks to cached credentials), but as I've noted before, I struggled with managing Hyper-V from the command line. I had seen some examples of how to do it using PowerShell, but never anything from a simple command console. Note that I never did install PowerShell on my Server Core boxes.

Fortunately, last Sunday I found Ben Armstrong's post for Starting a Hyper-V Virtual Machine which shows not only the PowerShell version that I had seen before, but also a WMI version (which can be used with plain old VBScript). While Ben's code certainly works, I ended up snarfing some similar sample code from MSDN to create a new ManageVM.vbs script (which seems more intuitive -- at least to me -- than using "StartVM.vbs" to stop a VM).

Now, whenever I am unable to manage my Hyper-V servers remotely, I can use something like the following to start one of the VMs:

cscript \NotBackedUp\Public\Toolbox\Scripts\ManageVM.vbs XAVIER1 start


No comments posted yet.

Add Comment

Optional, but recommended (especially if you have a Gravatar). Note that your email address will not appear with your comment.
If URL is specified, it will be included as a link with your name.

To prevent spam from being submitted, please select the following fruit: Grapes

Please add 3 and 2 and type the answer here: