John Howard from Microsoft published a script to convert generation 1 VMs to generation 2.
Check it out here.
Convert-VMGeneration converts a generation 1 virtual machine running in Hyper-V on Windows Server 2012 R2 or Windows 8.1 to generation 2.
It will not convert a virtual machine that
- Has checkpoints
- Has Hyper-V replica enabled (experimental support with -IgnoreReplicaCheck)
- Is running
- Uses virtual hard disk sharing
- Is running a 32-bit guest operating system
- Is running a non-Windows guest operating system
- Is running a Windows guest operating system prior to Windows 8 and Windows Server 2012