Question

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) ?

Was it helpful?

Solution

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.

OTHER TIPS

This is not completely true. In WSS2008R2, when changing default VM data root, nothing is written in the system data root. To find the data root of a single VM, you need to look in Msvm_VirtualSystemGlobalSettingData, search for SystemName property matching your VM GUID and look in ExternalDataRoot and SnapshotDataRoot properties to see the VM related folders.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top