Lab Ops Redux setting up Hyper-V in a hurry

I am at Manchester United as I write this and one of the delegates wanted to quickly try out Hyper-V in Windows Server 2012R2.  I thought I had an all up post on that but it turns out I don’t, so Nicholas Agbaji this is just for you!

You’ll need a latptop/desktop running Windows 7/Windows 2008R2 or later to work on that’s capable of running Hyper-V, and that the BIOS is setup for virtualization

  • You’ll need to download a copy of Windows Server 2012R2 and a special PowerShell script Convert-WindowsImage.ps1 from the TechNet Gallery.
  • Run the PowerShell script as follows. 

.\Convert-WindowsImage.ps1 –SourcePath <Path to your iso> -Size 50GB -VHDFormat VHD –VHD “C:\WS2012R2.VHD” -Edition "ServerStandardEval"

Note: If you are running on Windows 8 or Windows Server you can use the newer VHDX format for virtual hard disks

  • We now have a VHD with a sysprepped clean copy of Windows Server 2012R2 and Windows 7/2008R2 & later allows us to boot from a VHD just like the one we just made.
  • To boot from VHD we need to mount the VHD. In Windows 8/2012 you can simply click on a VHD to mount it, however in Windows 7/2008R2 then we’ll need to open an elevated command prompt and do this manually:
    • diskpart
    • select vdisk file =”<path to your VHD>”
    • attach vdisk
  • We’ll now get an additional drive say drive H: and now we’ll need to edit the boot database from an elevated command prompt and add and edit a new entry to register the VHD:
    • bcdboot g:
  • We also need to edit the BCD to get Hyper-V to be enable in our VHD with
    • bcdedit /set “{default}” hypervisorlaunchtype auto
  • Optionally you could describe your new boot entry with
    • bcdedit /set “{default}” description “Windows Server 2012R2 Lab Ops”
  • Reboot you server/laptop and you’ll have an extra boot option to boot to windows server.
  • The final step is to add in  the Hyper-V role either from Server Manager or with Powershell..
    • add-WindowsFeature hyper-v –IncludeManagementTools 

Once you have this VHD setup you can boot into your OS and backup the VHD you made and possibly reuse it on another machine.  So good luck Nicholas and thanks for spending the day with us!