Quantcast
Channel: Remote Administration For Windows » Scripts
Viewing all articles
Browse latest Browse all 12

Turn virtual machines on and off from a script (Hyper-V)

$
0
0

Post image for Turn virtual machines on and off from a script (Hyper-V)

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:

c:\windows\system32\cscript.exe HManage.vbs [name] [option]

The name is the name of your virtual machine

The three options are:

start – start the VM

stop – stop the VM

forcestop – Force a shutdown of the VM (Could lose data)

You can download it from here:

HManage.dat

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.


Viewing all articles
Browse latest Browse all 12

Trending Articles