none
HyperV using WMI RRS feed

  • Question

  • Hello,

    we plan to use the VHD APIs (https://msdn.microsoft.com/en-us/library/windows/desktop/dd323700(v=vs.85).aspx) to manage the VMs. As per this reference guide, the api TakeSnapshotVhdSet() is supported only with Windows 2016 server.

    What API to be used for creating the checkpoint (snapshot) in windows 2008, win 2012 servers?

    Thanks in advance

    -Balu

    Monday, November 30, 2015 9:08 AM

Answers

All replies

  • On those platforms you would take a snapshot, and you would use the v1 namespace example:

    v2 namespace explanation: http://blogs.msdn.com/b/virtual_pc_guy/archive/2013/06/20/creating-a-virtual-machine-with-wmi-v2.aspx

    v1 namespace WMI example: http://blogs.msdn.com/b/virtual_pc_guy/archive/2011/10/17/taking-a-snapshot-via-powershell-hyper-v.aspx


    Brian Ehlert
    http://ITProctology.blogspot.com
    Learn. Apply. Repeat.

    • Marked as answer by Bala_T Tuesday, December 1, 2015 7:24 AM
    Monday, November 30, 2015 5:30 PM
    Moderator
  • The other query are

    (1) when the snapshot is created, do we have WMI calls to perform 

    1. consolidation of delta changes (I think ApplyVirtualSystemSnapshot to be used)
    2. Destroy/remove snapshot without consolidating the delta changes (???)

    (2) Is there a way to uniquely identify the disks of the VM ? Any GUID associated with VM virtual hard disks ?

    disknames are not unique, as they can be created with the same names using hyperv manager. 

    Tuesday, December 1, 2015 7:36 AM
  • Deleting a snapshot will consolidate the delta disks.

    You can either Revert to a previous snapshot or you can apply a previous snapshot then delete the branch that remains.

    Each disk has an identifier that is unique to the virtual storage management layer.  However, the disk path is something that must also be unique.

    In Ben's blog there are WMI samples of finding all of the attached disks, using the WMI association classes.

    It also occurred to me that this post might be useful to you: http://itproctology.blogspot.com/2011/11/hyper-v-wmi-association-null-returns.html


    Brian Ehlert
    http://ITProctology.blogspot.com
    Learn. Apply. Repeat.

    Tuesday, December 1, 2015 2:00 PM
    Moderator
  • Thanks. Appreciate your quick response.

    1. To identify the disks

    http://blogs.msdn.com/b/virtual_pc_guy/archive/2010/08/10/find-all-virtual-hard-disks-associated-with-a-virtual-machine-script.aspx 

    Looks lot of the class used in the above example are obsoleted with windows 2k12.

    Do you have such script that finds the disks ?

    2. Hard disk Identifier ??

    GetVirtualHardDiskInfo method of the Msvm_ImageManagementService class - obsoleted in windows 2012. This returns Msvm_VirtualHardDiskInfo object. But this does not contain the virtual disk ID.

    But the virtual disk Id is available from windows 2012 as part of the Msvm_VirtualHardDiskSettingData class. 

    How to get the Virtual hard disk ID for the Windows 2008, 2008 R2.



    Wednesday, December 2, 2015 9:05 AM