Restore a raw copy of Hyper-V configuration files.

Today I'll try to explain how to recovery Hyper-V VMs from a raw copy of configuration files. My experience start from a new installation of Windows 8 on my notebook.

Before formatting I'v backup C:\ProgramData\Microsoft\Windows\Hyper-V with a raw copy of all files on my external disk. When i'v finished to install all components of my new Windows 8 installation I'v restore the content of previous directory. But when I've launched the Hyper-V console I can't see no VM. At that moment my first question was: Why cannot view VMs if XML files are restored?

Searching with Google I'v found this article when is explained that configuration files have a special permission "NT VIRTUAL MACHINE\{VM_GUID}" to be restored, where {VM_GUID} is the name of XML file.

If you have, like me, a lot of VMs you can use this simple bat script that i write for restore a single VM.

SET VMID=7E3FEDA5-CC67-49FB-8372-23B3F6E1E85D
icacls "%systemdrive%\programdata\Microsoft\Windows\Hyper-V\Virtual Machines\%VMID%.xml" /grant "NT VIRTUAL MACHINE\%VMID%":(F) /L
icacls "%systemdrive%\programdata\Microsoft\Windows\Hyper-V\Virtual Machines\Locks\%VMID%.lock" /grant "NT VIRTUAL MACHINE\%VMID%":(F) /L
net stop vmms
net start vmms

NB: Remember to launch this script as an administrator because it restart the vmms service.

I hope that this article may be useful for you.


Nessun commento:

Posta un commento