Written by 3:56 pm Microsoft, Microsoft Azure, PowerShell, Virtualization, Windows, Windows Server • 7 Comments

Windows Sysprep for Virtual Machines

sysprep.exe vm mode

For using the same system image for different virtual machines or physical computer, Microsoft created a tool called sysprep.exe. This blog post covers Most people should be already familiar with that tool. If not here is the description:

Sysprep prepares a Windows installation (Windows client and Windows Server) for imaging, allowing you to capture a customized installation. Sysprep removes PC-specific information from a Windows installation, “generalizing” the installation so it can be reused on different PCs. With Sysprep you can configre the PC to boot to audit mode, where you can make additional changes or updates to your image. Or, you can configure Windows to boot to the Out-of-Box Experience (OOBE).

This is great so you can sysprep a virtual machine copy the VHD or VHDX file and use it for the first boot of different VMs. In Windows Server 2012 and Windows 8, Microsoft added an addition to sysprep called the mode switch “/mode:vm”. The mode:vm switch allows you to identify the Windows as a Virtual Machine and sysprep.exe will generalize a Virtual Hard Disk (VHD or VHDX) so that you can deploy the VHD as a VHD on the same Virtual Machine (VM) or hypervisor. You must deploy the VHD on a Virtual Machine (VM) or hypervisor with the same hardware profile. For example, if you created VHD in Microsoft Hyper-V, you can only deploy your VHD to Microsoft Hyper-V VMs with a matching hardware profile, and you can only run VM mode from inside a VM.

This will boost the performance and time for the virtual machine for the first startup and installation. This also work of course with virtual machines running on other hypervisors such as VMware or Xen.

Run the following command inside the Virtual Machine (You find sysprep.exe in the  C:\Windows\System32\Sysprep folder):

 
sysprep.exe /oobe /generalize /shutdown /mode:vm

Now you can copy the VHD or VHDX file from that virtual machine and use it for other VMs. Also check out my post about automating VM creation using an unattend.xml file.

Tags: , , , , , , , , , , , , , , , , Last modified: January 28, 2019
Close Search Window
Close