Updated features for exporting a virtual machine
With the updated Hyper-V features in Windows Server 2012 R2, you can export a live VM and its snapshot without shutting down the VM, which had to be done in Windows 2012. This helps the administrator to avoid unnecessary downtime for the virtual machine export. There are two cmdlets that can be used for the live export of virtual machines and its snapshots; these are the Export-VM
and the Export-VMSnapshot
cmdlets.
The Export-VM
cmdlet exports a virtual machine to disk. This cmdlet creates a folder at a specified location with three subfolders: Snapshots
, Virtual Hard Disks
, and Virtual Machines
. The Snapshots
and Virtual Hard Disks
folders contain the snapshots and the VHDs of the specified virtual machine respectively. The Virtual Machines
folder contains the configuration XML of the specified virtual machine. The following command exports all virtual machines to root of the D
drive. Each virtual machine will be exported to its own folder:
Get-VM | Export-VM –Path D:\
The export of a live VM is very different from the export of a snapshot of a live VM. The export of a live VM can be done by creating a snapshot first, then exporting it, and then finally removing the snapshot. The following cmdlet shows you how to do this:
Get-VM | Checkpoint-VM| Export-VMSnapshot -path d:\ | Remove-VMSnapshot
The Export-VMSnapshot
cmdlet exports a virtual machine snapshot to disk:
PS C:\>Export-VMSnapshot –Name 'Base Image' –VMName TestVM –Path D:\
The preceding command exports the Base Image
snapshot of the TestVM
virtual machine to D:\
.