Hyper-V WMI: Import virtual machine and create snapshot
Question
I'm using the Hyper-V WMI Provider to import virtual machines in Hyper-V, specifically using the ImportVirtualSystemEx
method of the Msvm_VirtualSystemManagementService
class, largely using the C# code snippets provided by MS.
I need to create a snapshot immediately after import, using the CreateVirtualSystemSnapshot
method, but I can't figure out how to identify the newly imported virtual machine among all the other virtual machines that have already been imported in Hyper-V.
I was hoping to get something back from the ImportVirtualSystemEx
method, but that doesn't seem to be the case.
Any clues?
Solution
I just realised that the Msvm_VirtualSystemImportSettingData
class that is created using the GetVirtualSystemImportSettingData
method during import contains all the information I need.