Creating Windows machine template has become important part of automation and testing. In this tutorial I will cover different aspect of creating a VM template. This similar for VMWare, OracleBox, KVM and most general virtualization technology.

Depending on how you use the template there might have slight difference in the approach.

  1. You want to consider if you want to have an image that has the latest update of creating the image, although it is a good practice but that might also impact the size of the VM.
  2. For KVM environment you would want to make sure that you have updated at least the network drivers using the virtio driver as that will be consistent across all your KVM environment so it is good to have that done before you create a template.
  3. If you want to have a consistent Administrator Account you would want to do that first. Here are the steps to do it. There are multiple ways but I am showing you the GUI way.Launch the lusrmgr.msc
Uncheck Account is disabled
Set a Password

Once you have done the update and Administrator account activation. You can delete the user account that you have created during the install. That will give you a image that doesn’t have duplicated username and password and you will be able to use Administrator account in all subsequent images. You can also create a general admin account without going through this step as well.

You run the following command to perform a non-interactive sysrep and shutdown when done and you can use this image to create new VMs. The /generalize option will change the SID, /oobe is use for the account setting.

C:\Windows\System32\sysprep\sysprep /oobe /generalize /shutdown