6

I have standalone win 2012 r2 server with hyper-v on it. It is my test server I use for experiments so it can be turned off anytime. That's not a problem.

Is it possible to import 2012r2 VMs to 2016 hyper-v without exporting them? Something like loading vbox files to virtualbox without the need of exporting machines in the first place? I'm running low on disk space and I would like to do clean install of host os and then somehow get back my current virtual machines to new hyper-v but without exporting and importing them. So they would still be in the same place they are now but just register them in hyper-v without much of IO operation to export and import them back.

I don't want to do in place upgrade of host os but clean install of 2016 and then load my vms.

Is it possible? If yes then how?

termil0r
  • 123
  • 1
  • 6

2 Answers2

7

If you have the files, both the vhd(x) and the machine vmx file, and your system is configured the same with similar vSwitch names then you should be able to use the command Import-VM -Register path\to\the\file.vmx.

If you no longer have your VMX files then you should just re-create a new virtual machine and when asked about adding storage, use the existing vhd(x) files that you already have.

Zoredache
  • 128,755
  • 40
  • 271
  • 413
  • 1
    When recreating, you do have to choose the VM generation that matches the original generation, or it won't be able to boot from the VHD/VHDX. luckily if it's not documented, you can just guess and try again if you guess wrong the first time. – Todd Wilcox Oct 28 '17 at 19:30
  • Verified working! On Windows Server 2016 there's new file format VMCX but it's the same thing. I just had to point to this file when importing-vm as @Zoredache said. Thanks. – termil0r Jan 28 '18 at 13:25
1

Building on the instruction to use Import-VM, the following powershell script will import all VMs in the folder in-place, whether they are the older xml files or the newer vmcx files. Safe to run on a folder where some are already registered, as Import-VM will just show an error and move on.

Just set the BaseFolder appropriately and execute.

$baseFolder='Q:\Hyper-V\Virtual Machines\'
$vms=Get-ChildItem $baseFolder -Recurse | where {$_.extension -in ".xml",".vmcx"}
$vms |  ForEach {
    Write-Output "Importing $_"
    Import-VM -Path $_.FullName -Register
}

Read-Host -Prompt "Press Enter to continue"