Latest Version

Version 1.04 6th December 2013

Please read this for more information on this script including tips and further examples, or this for a detailed manual walkthrough of the overall steps this script follows.


If you find Convert-VMGeneration useful, please drop me an email through my blog or provide a rating above ^^^. Thank you! :)

About

Convert-VMGeneration converts a generation 1 virtual machine running on Hyper-V in Windows Server 2012 R2 or Windows 8.1 to generation 2. It does not change the source generation 1 virtual machine during the process - a new virtual machine is created with a new boot disk.

Convert-VMGeneration.ps1 is self-documenting. After saving to a local disk, run "get-help .\Convert-VMGeneration.ps1" from a Windows PowerShell prompt.

Due to virtual hardware differences between a generation 1 and generation 2 virtual machines, certain devices such as floppy disk drives, DVD drives using physical media, legacy network adapters and COM: ports are not migrated. Additional data or recovery image partitions on the boot disk are not migrated.

Due to the highly destructive action of wiping a disk (the new boot disk for the generation 2 virtual machine) during the conversion process, the warning check and prompt for user configuration cannot be overridden. You should make absolutely sure before confirming that the right disk is about to be wiped. While every attempt has been made to validate there is not a bug in the code, no liability is accepted should accidental data loss occur. If in doubt, to minimise risks, run this script on a machine where no essential data exists, and use an exported/backup copy of the generation 1 virtual machine as the source for the conversion.
 

Requirements

Convert-VMGeneration must be run on Windows 8.1 or Windows Server 2012 R2 with the Hyper-V feature/role enabled. It has not been tested on server core installations of Windows Server 2012 R2 or Microsoft Hyper-V Server 2012 R2. Convert-VMGeneration supports the following guest operating systems:

Convert-VMGeneration will not convert a virtual machine that

Installation & Removal

Save Convert-VMGeneration.ps1 to a directory on the local disk (eg c:\Scripts\). There is no setup program. Run it from an elevated Windows PowerShell command prompt. To uninstall, simply delete the file. 

Known Issues

Acknowledgements

Many, many thanks to Stefan Wernli and Brian Young, both developers on the Hyper-V team. Without their assistance, on multiple occasions, I would never have succeeded in completing this project. 

I make no apologies in admitting that this was my first significant PowerShell undertaking. As such, any coding 'standard' should not be used as an example of how to write good PowerShell. Its style is more a cocktail fusion of my experiences in C, VB6, .NET and VBScript, with a twist of "that'll get the job done" and "dumb luck" :) It does however have some great examples of VM cloning, in particular networking cloning (thanks again Brian!).

Disclaimer

Although I work for Microsoft and am a Program Manager in the Hyper-V team, I must point you to the disclaimer on my blog, the disclaimer in files associated with this project, and the license conditions at the top of this page before use. Convert-VMGeneration.ps1 and any associated files are provided "as-is". You bear the risk of using it. No express warranties, guarantees or conditions are provided. It is not supported or endorsed by Microsoft Corporation and should be used at your own risk.

Legal & jargon-free moment - although this tool itself is unsupported, the steps and processes the tool follows to convert an operating system installation from generation 1 to generation 2, including dism, diskpart, bcdboot, cloning a VMs configuration, the use of reagentc for configuring the recovery environment and anything I missed in that list are supported. Everything the tool does uses APIs, applications and recommendations fully documented/supported in the ADK, Technet and/or MSDN.

Thanks,
John