Manage Hyper-V Virtual machines using WMI and VBS scripts

Today I was working on how to manage Hyper-V virtual machines using WMI.
This VBS scripts can be modified to suit your needs…
Each script takes one argument “machine name”:

listvm.vbs – display all virtual machines on Hyper-VĀ – this script will create a TXT file (you should edit path and filename inside the script) with all virtual machines that are on Hyper-V host. It will print names of the machines and current state (Running, Off, Saved)

sortvm.vbsĀ – this script alphabeticaly sorts list of virtual machines (you should edit path and filename inside the script)

startvm.vbs – usage: startvm.vbs “Name of your virtual machine” – this script will start the virtual machine

stopvm.vbs – usage: stopvm.vbs “Name of your virtual machine” – this script will turn of (dirty!) your virtual machine

shutdownvm.vbs – usage: shutdownvm.vbs “Name of your virtual machine” – this script will shut down your virtual machine if it is Integration Services aware – it will signal/notify guest operating system to initialize shutdown procedure. It works only on machines that support Hyper-V Integration services.

hardresetvm.vbs – usage: hardresertvm.vbs “Name of your virtual machine” – this script will reset (dirty!) your virtual machine

savestatevm.vbs – usage: savestatevm.vbs “Name of your virtual machine” – this script will save and turn off your virtual machine

I have compiled this scripts using resources regarding Hyper-V and WMI

Enjoy, WMI power!

Tags: , , , , ,

15 Responses to “Manage Hyper-V Virtual machines using WMI and VBS scripts”

  1. Rodwell Mazambara says:

    Great scripts. Do you have one for export and import?

  2. Yariv says:

    Thank you!
    Very helpful scripts.

  3. David says:

    Any scripts to take a snapshot and revert back to a snapshot?

  4. Gavin says:

    Thank you for your job.
    Is there any scripts can create a virtual system?

  5. vin says:

    Very helpful.

    Is there a way to get Virtual Machine Volume labels, Number of NICs, Disk provisioning types, number of CPUS, number of disks, RAM size in MB?

  6. vin says:


    Can any one reply to my abov query?

  7. sHANE says:

    Thanks for this post! Scripts worked great, you would think that microsoft would have had these built into the server software to start and stop vms from the command line…

  8. Satyendra says:

    Hey awsome script they are , i was searching too much for this thanx
    I want one more script pls provide that one ,script for making new virtual machine and adding vhd in that pls help me for that
    Thnaks and Regards

  9. Mike says:

    Love the scripts,

    I’m building an app to run these via over windows network to other hyperv hosts. Having a little trouble, is anyone having success doing anything like this ? I can get it all working from the app, running the command locally, but accross the network, not so much luck.

  10. Behrad says:


    Any idea how you can rename a snapshot using root\virtualization\v2?

  11. Nail says:

    Hard resetting doesn’t work. I try reset from c#, but nothing here

  12. Excellent post. I was checking constantly this blog and I am impressed!
    Very useful information particularly the last part šŸ™‚ I care for such info a lot.
    I was seeking this certain information for a long time.
    Thank you and good luck.

  13. Ken C says:

    Nice scripts. Thank you for posting.
    I will note I had to use WbemScripting.SWbemLocator to connect to my servers so I could use a username/password.

  14. Baha says:


    can anyone help about how to monitor the Hyper-v replication health in windows 2012 R2 ?

    do you have a vbs script to do that ?

Leave a Reply

You must be logged in to post a comment.