views:

398

answers:

1

I've looked at several objects in the "root\virtualization" name space but I have not been able to find where Hyper-V stores the path to the config file for a given virtual machine. I need to get this file path programmatically or at least just the home path of a given virtual machine would be fine as well. What WMI object and field stores the path to a given virtual machine (hint it's not Msvm_ComputerSystem) ?

+1  A: 

Get the DefaultExternalDataRoot property of Msvm_VirtualSystemManagementServiceSettingData to get the vm root, and append the Name property of Msvm_ComputerSystem (guid) and ".xml". Even if the VM is created in a non-default location, you'll see a symlink in the default external data root directory referencing the config file.