locked
How to programatically fetch all config/vhd files associated with a specific VM? RRS feed

  • Question

  • I need to get my hands on all file names associated with a given VM. As it stands now I (using the WMI/PowerShell) manually piece together lists of files using GUIDs and knowledge about where files are typically stored. I also walk WMI objects getting the names of .avhds  and .vhd. In the end I believe I have all the files, but is there a more robust method to get all of these? Something like an Export call but that doesn't perform the export or ? Thanks.
    ~billy
    Thursday, February 26, 2009 6:55 PM

Answers

  • There is no single command that will return VM X has all the physical files of Q, Y, R, T, V.

    What you are doing by programatically using WMI to find the VM then its dependant items is the same process that any programmer would need to do to (for example) select a single VM that is targeted for backup and be sure that all of necessary entities that make up that VM are properly discovered.

    Brian Ehlert (hopefully you have found this useful)
    • Proposed as answer by Vincent Hu Monday, March 2, 2009 2:09 AM
    • Marked as answer by Vincent Hu Monday, March 9, 2009 1:34 AM
    Saturday, February 28, 2009 8:15 PM

All replies

  • Taylor Brown has written an awsome script that does something like this (display VM -> VHD connections). It can be found here:
    http://blogs.msdn.com/taylorb/archive/2009/02/16/how-are-my-vhd-s-passthough-disk-s-connected-to-my-virtual-machine.aspx

    Hope this helps you.

    Kind regards,
    Floris van der Ploeg

    Friday, February 27, 2009 8:07 AM
  • Hi, Thanks. Unfortunately, that script only shows the currently connected .vhd or .avhd file. I'm looking for a single call that gets all files associated - including .xml config files, etc. I'm able to accomplish my goal already using a bit of patch work, but I was just wondering if there is a specific call that does it for me. Thanks.
    ~billy
    Saturday, February 28, 2009 3:17 AM
  • Well there's nothing in the root\virtualization WMI namespace or registry to indicate there is. All you can do is grab the global settings by Element Name to get the System Name and Data Root and append Virtual Machines/<GUID>.xml to get your config file. Then just enumerate over the Resource Allocations by "Hard Disk Image."
    Saturday, February 28, 2009 10:34 AM
  • There is no single command that will return VM X has all the physical files of Q, Y, R, T, V.

    What you are doing by programatically using WMI to find the VM then its dependant items is the same process that any programmer would need to do to (for example) select a single VM that is targeted for backup and be sure that all of necessary entities that make up that VM are properly discovered.

    Brian Ehlert (hopefully you have found this useful)
    • Proposed as answer by Vincent Hu Monday, March 2, 2009 2:09 AM
    • Marked as answer by Vincent Hu Monday, March 9, 2009 1:34 AM
    Saturday, February 28, 2009 8:15 PM