Useful Tools for Hyper-V Administrators

Microsoft recently updated two tools that are useful for IT pros who are deploying Hyper-V: Convert-WindowsImage and Disk2vhd. These updates include support for Windows Server 2012 R2 and Windows 8.1.

Tools for Hyper-V Admins

Convert-WindowsImage 6.3

The Convert-WindowsImage.PS1 script is a free download from the TechNet Script Center gallery. Convert-WindowsImage has been around since the preview releases of Windows 8 and Windows Server 2012, replacing WIM2VHD. You can use this tool to create a virtual hard disk (VHD or VHDX formats) for a virtual machine from the installation media (ISO file) of Windows. For example, say you have downloaded Windows Server 2012 R2 and you’d like to quickly deploy a generalized (Sysprep) virtual machine as quickly as possible. Fire up Convert-WindowsImage, create a new VHDX, and attach it to a virtual machine. Boot up the virtual machine, answer the mini-setup wizard questions, and you have your WS2012 machine up and running.

Convert-WindowsImage is easy to use. You can run the tool completely from the PowerShell prompt (enable the execution of scripts first with either Set-ExecutionPolicy or Active Directory Group Policy); all the instructions can be found on the download page. That option might be useful for regular VM builds from the original Microsoft media (should be rare for most of us because we should use VM templates). Alternatively you can run the tool with the –ShowUI flag to open up a graphical interface and supply all the information there. This approach is much easier, and probably useful for those of us who only create a new virtual machine template whenever Microsoft releases new Windows media.


Sponsored Content

Passwords Haven’t Disappeared Yet

123456. Qwerty. Iloveyou. No, these are not exercises for people who are brand new to typing. Shockingly, they are among the most common passwords that end users choose in 2021. Research has found that the average business user must manually type out, or copy/paste, the credentials to 154 websites per month. We repeatedly got one question that surprised us: “Why would I ever trust a third party with control of my network?

Creating a VHDX directly from Windows media.

Using Convert-WindowsImage as above will install Windows Server 2012 R2 Datacenter into a new VHDX file. The Windows installation will be generalized as if you had run Sysprep. Note that you could create a VHD file (not that you should, unless you plan to upload the virtual machine to Azure or migrate it to a legacy version of Hyper-V), include an unattended answer file to automatically deal with the mini-setup wizard questions (and more), name the resulting VHDX file, and configure the working directory. You should also be aware that the tool can use a WIM file (such as install.wim as found in the Windows installation media) and that it can query for the possible images within your ISO or WIM file (I chose the full installation of the Datacenter edition).

Version 6.3 of Convert-WindowsImage adds support for creating GPT disks that are used by UEFI based machines. And that allows you to create a virtual hard disk that can be used by Generation 2 virtual machines.

I really like this tool. It might not be supported by Microsoft, but it gives me the quickest way to deploy a new VHD/X file that I can use for:

  • Bare metal host deployment: The resulting file can be used by System Center Virtual Machine Manager to deploy Hyper-V hosts to bare metal servers.
  • Virtual machine templates: A new virtual machine can be quickly deployed, manually updated, and recaptured as a template.


Disk2vhd V2.0

Another free tool, released under the Sysinternals banner (of Mark Russinovich fame), Disk2vhd gives you a free solution for converting physical disks into virtual hard disks. This is pretty important because – for some reason – Microsoft chose to remove the P2V (physical to virtual) conversion functionality from System Center Virtual Machine Manager 2012 R2. That leaves us with just Disk2VHD as the only Microsoft-provided option.

Disk2VHD is easy to use. Download and extract the zip file before running the executable file on the physical server that you want to capture. By default it will create a VHDX file (new in this version). Application consistency is maintained by creating the virtual hard disk from a Volume Shadow Copy Service (VSS) snapshot. Note that any changes to the capture physical disk(s) after this snapshot will be lost, so shut down any services on the physical machine first.

Check which disks you want to capture and run the tool. You will have a new virtual hard disk that you can attach to a virtual machine when the job is finished. Your original physical server is left untouched so make sure you run either the physical machine or the virtual machine, but not both on the same network at the same time.

Disk2vhd V2.0

Running Disk2vhd to convert a physical disk to a VHDX


Neither of these free tools is supported by Microsoft. However, the creators of these tools have tested them pretty well, and at this time the tools support the latest editions of Windows and Hyper-V.

Related Topics:

Aidan Finn, Microsoft Most Valuable Professional (MVP), has been working in IT since 1996. He has worked as a consultant and administrator for the likes of Innofactor Norway, Amdahl DMR, Fujitsu, Barclays and Hypo Real Estate Bank International where he dealt with large and complex IT infrastructures and MicroWarehouse Ltd. where he worked with Microsoft partners in the small/medium business space.
Don't leave your business open to attack! Come learn how to protect your AD in this FREE masterclass!REGISTER NOW - Thursday, December 2, 2021 @ 1 pm ET

Active Directory (AD) is leveraged by over 90% of enterprises worldwide as the authentication and authorization hub of their IT infrastructure—but its inherent complexity leaves it prone to misconfigurations that can allow attackers to slip into your network and wreak havoc. 

Join this session with Microsoft MVP and MCT Sander Berkouwer, who will explore:

  • Whether you should upgrade your domain controllers to Windows Server
    2019 and beyond
  • Achieving mission impossible: updating DCs within 48 hours
  • How to disable legacy protocols and outdated compatibility options in
    Active Directory

Sponsored by: