How to Export and Import Hyper-V Virtual Machines on Windows Server 2012 R2
Exporting and importing virtual machines is a fundamental Hyper-V administrative skill used for VM backup, migration between hosts, cloning, and archiving. Windows Server 2012 R2 significantly improved the export and import workflow compared to previous versions — exports now occur without needing to shut down the VM, and importing a VM can be done with or without copying the VM files, allowing reuse of existing disk locations. This guide covers the full export and import process using both Hyper-V Manager and PowerShell.
Prerequisites
- Windows Server 2012 R2 with the Hyper-V role installed
- Sufficient disk space at the export destination
- Administrative privileges on the Hyper-V host
- For cross-host imports: network share or removable storage to transfer export files
Understanding the Export Format
A Hyper-V VM export creates a directory containing:
- Virtual Machines folder: Contains the VM configuration XML file and runtime state files (
.vmcx,.vmrs) - Virtual Hard Disks folder: Contains all VHD/VHDX files associated with the VM
- Snapshots folder: Contains any checkpoint data if checkpoints were present
On Windows Server 2012 R2, the configuration file is an XML file named with the VM’s GUID. Starting from Windows Server 2016, the format changed to binary .vmcx, so 2012 R2 exports may not import directly into Windows Server 2016+ without compatibility checks.
Step 1 — Export a Running or Stopped VM
Windows Server 2012 R2 supports exporting a VM while it is running. The export captures the VM’s current state and configuration:
Export-VM -Name "ProductionServer01" -Path "E:VM-Exports"
This creates the directory E:VM-ExportsProductionServer01 containing all VM files. To export all VMs on the host:
Get-VM | Export-VM -Path "E:VM-Exports"
To export to a network share:
Export-VM -Name "ProductionServer01" -Path "\backup-serverHyperV-Exports"
Note: The Hyper-V service account must have write access to the export destination. For network shares, ensure the computer account of the Hyper-V host has permission to write to the share.
Step 2 — Monitor Export Progress
For large VMs, the export may take considerable time. Monitor the operation status:
$ExportJob = Export-VM -Name "ProductionServer01" -Path "E:VM-Exports" -AsJob
$ExportJob | Wait-Job
$ExportJob | Receive-Job
Step 3 — Verify the Export
After the export completes, verify the exported files are present and the sizes look correct:
Get-ChildItem -Path "E:VM-ExportsProductionServer01" -Recurse | Select-Object FullName, Length | Format-Table -AutoSize
# Check the total size:
(Get-ChildItem -Path "E:VM-ExportsProductionServer01" -Recurse | Measure-Object -Property Length -Sum).Sum / 1GB
Step 4 — Compare a VM Before and After Export
To capture a hash of the VM’s virtual disk for integrity verification:
Get-FileHash -Path "E:VM-ExportsProductionServer01Virtual Hard DisksProductionServer01.vhdx" -Algorithm SHA256
Step 5 — Import a VM on the Same Host
Windows Server 2012 R2 provides three import types:
- Register the virtual machine in-place: Uses the existing files at their current location, registers the VM with the Hyper-V host. No files are copied
- Restore the virtual machine: Copies the VM files to the default Hyper-V storage paths, then registers it. The original files remain at the export location
- Copy the virtual machine: Creates a full copy with a new unique ID, allowing you to run both the original and the copy simultaneously
To register a VM in-place (fastest, no file copy):
Import-VM -Path "E:VM-ExportsProductionServer01Virtual Machines{GUID}.xml" -Register
To restore the VM (copies files to default paths):
Import-VM -Path "E:VM-ExportsProductionServer01Virtual Machines{GUID}.xml"
To copy the VM with a new unique ID (creates an independent clone):
Import-VM -Path "E:VM-ExportsProductionServer01Virtual Machines{GUID}.xml" -Copy -GenerateNewId -VhdDestinationPath "D:VMs" -VirtualMachinePath "D:VMConfigs"
Step 6 — Import a VM on a Different Host
To import a VM on a different Hyper-V host, transfer the export directory and then import. Specify destination paths for VHDs if they differ from the original:
# Find the configuration file path:
$ConfigPath = Get-ChildItem -Path "\new-hostHyperV-ExportsProductionServer01Virtual Machines" -Filter "*.xml" | Select-Object -First 1 -ExpandProperty FullName
# Import with copy and new ID on the destination host:
Import-VM -ComputerName "HV-Host02" -Path $ConfigPath -Copy -GenerateNewId -VhdDestinationPath "D:VMsProductionServer01" -VirtualMachinePath "D:VMConfigsProductionServer01"
Step 7 — Verify the Imported VM
After importing, verify the VM appears in Hyper-V and its configuration is intact:
Get-VM -Name "ProductionServer01"
Get-VMHardDiskDrive -VMName "ProductionServer01"
Get-VMNetworkAdapter -VMName "ProductionServer01"
Start the VM and verify it boots correctly:
Start-VM -Name "ProductionServer01"
Get-VM -Name "ProductionServer01" | Select-Object Name, State, Uptime
Exporting VMs with Checkpoints
If a VM has checkpoints, the export includes all checkpoint data in the Snapshots folder. When imported, the checkpoints are also available. This is useful for preserving a rollback point when migrating a VM. However, for production migrations where checkpoints are not needed, consider merging all checkpoints before export to reduce export size and simplify the imported VM state:
# Remove all checkpoints before export to get a clean single-state VM:
Get-VMCheckpoint -VMName "ProductionServer01" | Remove-VMCheckpoint -IncludeAllChildSnapshots
# Wait for the merge to complete before exporting
Get-VM -Name "ProductionServer01" | Select-Object Name, Status
Automating Bulk VM Export
$ExportRoot = "E:VM-Exports"
$Timestamp = Get-Date -Format "yyyyMMdd"
Get-VM | Where-Object { $_.State -ne "Saved" } | ForEach-Object {
$ExportPath = Join-Path $ExportRoot "$($_.Name)-$Timestamp"
Write-Host "Exporting $($_.Name) to $ExportPath"
Export-VM -Name $_.Name -Path $ExportPath
}
Summary
VM export and import on Windows Server 2012 R2 Hyper-V provides a flexible mechanism for VM backup, cloning, and cross-host migration. The three import modes — register in-place, restore, and copy with new ID — cover the full range of use cases from rapid host recovery to creating independent test clones. For production environments, combining regular VM exports with integrity verification creates a reliable offline backup strategy that complements Hyper-V Replica’s real-time replication capabilities.