How To Start VMs On A Hyper-V Server Core

I was unfamiliar with Hyper-V Server and when I had to relocate the server to another physical location, I did not do sufficient checks to enable me to bring the server back up.

It turned out that the server was not configured to start VMs when booted, and when I realised, it was already too late. The issue was compounded by the fact that the server was not in the same domain as the rest of the network and the actual domain controllers are geographically in another country of which I have no access.

If your Hyper-V Server, and DCs can talk to each other, you only need another client (e.g Windows 7) to be available and install the Hyper-V Manager. Otherwise, you will have to type commands into the command line prompt that Hyper-V Server Core greets you on log in. After much struggle, I finally found the commands using the powershell solution.

#The name of the virtual machine to be started
$VMName = “Windows Server 2003”

#Get the VM Object
$query = “SELECT * FROM Msvm_ComputerSystem WHERE ElementName='” + $VMName + “‘”
$VM = get-wmiobject -query $query -namespace “root\virtualization” -computername “.”

#Request a state change on the VM
$Result = $VM.RequestStateChange(2)

In my case, I had to guess a lot of things from administrator username, password, $VMName, IPs to finally solve the problem.