I got a question from Andrea this week:
“Hi Steve,
We have some VMs under HyperV that are used for training during the day and we would like to setup a vbscript that could be called from windows scheduler that could start them up in the morning, and shut them down at the end of the day. Is this possible?”
Very good question. Thankfully Microsoft has put Hyper-V into WMI, making it quite simple to do this.
I have written a script you can call from the command line this:
The name is the name of your virtual machine
The three options are:
stop – stop the VM
forcestop – Force a shutdown of the VM (Could lose data)
You can download it from here:
You will need to rename it to .vbs after downloading.
Keep in mind that this needs to be run on the actual Hyper-V Server to work.
One more thing…Subscribe to my newsletter and get 11 free network administrator tools, plus a 30 page user guide so you can get the most out of them. Click Here to get your free tools
{ 3 comments… read them below or add one }
Thanks for the script steve. Been wanting to do this with a test vm for a while, and have not had time to look – thanks for the time saver.
Steve,
Is there a way to do this with VMWare? Specifically ESX
Hello Jessie,
I am not saying it is impossible, but it is much more complicated. The reason is you can’t run VBScript right on the ESX server (It is not Windows based). There might be some hooks in the VMWare client once you have it installed, but I have not tried that yet.