I believe in Hyper-V!

Windows 8.1Category Archives

Hyper-V did not find virtual machines to import from location “*”… migration from 2K8R2 to WS2012R2

As I said a few times so far, I have been writing blog posts to be my reminder and help to other blog readers :). Two days ago I migrate one of virtual machines from Windows Server 2008 R2 Hyper-V host to Windows Server 2012 R2 Hyper-V host. As many times until now I did Export then copy to the new storage and then Import, but… I forgot that I already did that a few months ago and what first need to do :). I got error like in the picture below ;)

1

This isn’t something new. I rewrite Rhoderick’s and Taylor’s articles. Thank you guys.

VM’s that are exported from Windows Server 2008 or 2008 R2 utilized the version 1 WMI namespace which resulted in a .exp file to represent the exported virtual machine. In Windows Server 2012 we introduced a new WMI namespace (version 2 or root\virtualization\v2) which implemented a much better import/export model – allowing you to effectively just copy the virtual machine folder (with the VM’s XML configuration file inside it) as well as the VM’s VHDs and then import that directly. For Windows Server 2012 we maintained the version 1 WMI namespace which allowed for importing of Windows Server 2008/R2 VM’s on 2012.

In Windows Server 2012 R2 we have removed the old version 1 namespace which means we can’t import virtual machines that where exported from Windows Server 2008/R2. However we can import them if you copy the virtual machine xml file and VHD’s – to do this you need to stop the vmms on the 2008/R2 server – copy all of the virtual machine files/vhds to the Windows Server 2012 R2 server and then import them.

What to do? We have two solutions!

The first is as follows:

Shut down all Hyper-V virtual machines on the WS2008R2 host then stop the Hyper-V Virtual Machine Management service.

1

net stop "Hyper-V Virtual Machine Management"

1

Copy all virtual machines what you want to migrate to WS2012R2 Hyper-V host then Import Virtual Machine… That’s easy way, but…

1

What if we already did Export and we don’t have WS2008R2 Hyper-V host?

The second resolution is as follows:

Exported Hyper-V virtual machines copy on the Windows Server 2012 and import them, then simple copy to a Windows Server 2012 R2. That server is only used to perform the import thus allowing the VM to be copied to Windows Server 2012 R2.

Now we can do whatever we want to do :)

I worked over the holidays and from tomorrow I’m going to deserved break until the end of the week.

Enjoy the day!

Romeo

Create New Generation 2 Virtual Machine with PowerShell – fundamentals

In this blog post I’d like to explain how to create Generation 2 Virtual Machine in few seconds with PowerShell. This .ps1 script is a very simple and you can create just one VM but you can edit it for your needs.
In the last two years on my lectures I noticed that many of attendees don’t understand the basics and also they are ashamed to ask in the front of other attendees. For that reason I want to help them!

This is my way how to create VM. I used PowerShell ISE for the better look

Step 1.

1

Step 2.

Type command like in the picture below, edit what you need to edit and press Run Script (F5).

2

### create client generation 2 virtual machine ###
New-VM -Name ATDGen2 -Path "C:\Hyper-V" -Generation 2 -SwitchName WiredLan
Set-VM -Name ATDGen2 -ProcessorCount 2 -DynamicMemory -MemoryStartupBytes 512MB -MemoryMinimumBytes 512MB -MemoryMaximumBytes 2048MB
New-VHD -Dynamic -SizeBytes 37GB -Path "C:\Hyper-V\ATDGen2\VirtualHardDisk\ATDGen2.vhdx"
Add-VMHardDiskDrive -VMName ATDGen2 -Path "C:\Hyper-V\ATDGen2\VirtualHardDisk\ATDGen2.vhdx"
Add-VMDvdDrive -VMName ATDGen2 -Path "D:\Software\Microsoft\Windows8.1Ent\en_windows_8_1_enterprise_x64_dvd_2791088.iso"
Set-VM -Name ATDGen2 -AutomaticStartAction StartIfRunning -AutomaticStopAction ShutDown
Start-VM -Name ATDGen2

And voila, in the few seconds VM is created. You will need approximately two minutes for OS installation on SSD. As you can see, VM is Up & Running.

3

You can expect more fundamental things related to virtualization very soon.

Enjoy the day ;)

Romeo