Sync a Hyper-V VM Offline with Windows 8

One of the best features of Windows 8 is in my opinion Hyper-V. Before Windows 8 I had Windows Server 2008 R2 running on my laptop only for the Hyper-V feature. I have a server at home that I use for my study, but sometimes I want to get a VM on my laptop so I can use this offline. Therefore I created a little concept that can sync the VM to my laptop and back to the server.

My server is running Windows Server 2012 Core and my laptop Windows 8 both with the Hyper-V feature enabled. In my concept I use a virtual machine that is available on both machines. I recoded a video where I show the syncing between my server and laptop. The recording is playing real time and has not been fast forwarded.

Because this is a concept I have hard coded a couple of things. I have specified the remote Hyper-V server (Ryan-Server) and the VM that I want to sync (Seq-Win7). The $Sync variable is set based on local or remote. Local will sync the VM from the server to my local machine and remote will sync the VM back to the server.

The following section will set configuration settings. This contains the host configuration, VM ID’s and virtual hard disks locations.

This is the function to sync the local machine. First the VM’s are put in saved state before the content is copied. Based on the VM ID the bin, vsv and virtual hard disk is copied. These files are required to restore the saved state.

This function is used to sync from the local machine back to the remote host.

In the concept I used the following If statements for the sync action.

What would be nice is to create a form that can show all the available VM’s and by selecting a VM you can sync it offline. This way it can be more user friendly.

Try it yourself! The complete script is available here.
If you have any questions, suggestions or just a comment please leave them in the comments below.