Using Sysprep on custom-built Windows VMs

This article describes how to complete the Sysprep process on Windows virtual machines.

These instructions apply to newer Windows operating systems (for example: Windows 2008, Windows 2008 R2, Windows 2012) installed on empty Kyndryl Cloud Uplift VMs, as well as newer Windows VMs built outside of Kyndryl Cloud Uplift.

The steps listed below must be performed in the order they appear. Otherwise, the VM may not function properly.

Contents

Build the VM

If you’re building a new VM from scratch, follow the steps below.

To build the VM
  1. Deploy an empty Windows image from the Kyndryl Cloud Uplift public templates and install your operating system. For more information, see Building a VM from an ISO.
  2. Make sure your template’s Guest OS Type on the Hardware Settings page matches exactly the operating system you’re installing. For more information see Overview of VM hardware and guest OS settings.
  3. Optional:

    • Update your VMware hardware version to the latest version. For more information about checking your hardware version, see Checking VM hardware version
    • Edit your automatic network to use the following network settings; for instructions about editing these settings, see Editing an automatic network.
      • Network Name: Default Network
      • Network Type: Automatic
      • Subnet: 10.0.0.0/24
      • Visible to other networks: No
      • Customer DNS: No for both
      • Domain Name: skytap.example
    • If you want to edit the hostname, edit the hostname in Kyndryl Cloud Uplift before powering on the VM for the first time.
  4. Change the hostname within the guest OS to match the hostname that is set in Kyndryl Cloud Uplift. Then, restart the VM to force the hostname change to take effect.
  5. Install the current version of VMware Tools from the Kyndryl Cloud Uplift public assets library; for more information, see Installing and upgrading VMware Tools on Windows VMs.
  6. Run all Windows updates; you may need to run Windows Update several times to install all updates.
  7. Power off the VM.
  8. Save the VM as a template. This creates a backup copy that you can restore from later, if necessary.

Prepare to Sysprep

  1. Create an unattend.xml file in the Sysprep directory:
    1. Navigate to the following location within your VM: c:\windows\system32\sysprep
    2. Right-click within this folder, and select New > Text Document
    3. Name the new file unattend.xml
    4. If Windows asks if you’re sure you’d like to change the file extension, click YES.
    5. Right-click your new file, and select Open With > WordPad
  2. Paste the following text (from the appropriate answer file below) into your file, and save:

    <?xml version="1.0" encoding="utf-8"?>
    <unattend xmlns="urn:schemas-microsoft-com:unattend">
      <settings pass="windowsPE">
          <component
               name="Microsoft-Windows-Setup"
               processorArchitecture="AMD64"
               publicKeyToken="31bf3856ad364e35"
               language="neutral
               versionScope="nonSxS"
               xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
              <Display>
                  <ColorDepth>32</ColorDepth>
                  <HorizontalResolution>1024</HorizontalResolution>
                  <VerticalResolution>768</VerticalResolution>
              </Display>
            </component>
      </settings>
      <cpi:offlineImage
           cpi:source="wim:c:/sources/install.wim#Windows 10 Enterprise"
           xmlns:cpi="urn:schemas-microsoft-com:cpi" />
    </unattend>
    
    <?xml version="1.0" encoding="utf-8"?>
    <unattend xmlns="urn:schemas-microsoft-com:unattend">
       <settings pass="generalize">
           <component
               name="Microsoft-Windows-PnpSysprep"
               processorArchitecture="amd64"
               publicKeyToken="31bf3856ad364e35"
               language="neutral"
               versionScope="nonSxS"
               xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
               <PersistAllDeviceInstalls>true</PersistAllDeviceInstalls>
           </component>
       </settings>
       <settings pass="specialize">
           <component
               name="Microsoft-Windows-Shell-Setup"
               processorArchitecture="amd64"
               publicKeyToken="31bf3856ad364e35"
               language="neutral"
               versionScope="nonSxS"
               xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
               <Display>
                    <ColorDepth>32</ColorDepth>
                    <HorizontalResolution>1024</HorizontalResolution>
                    <VerticalResolution>768</VerticalResolution>
               </Display>
               <Themes>
                    <DefaultThemesOff>true</DefaultThemesOff>
                    <ScreenSaver>Off</ScreenSaver>
               </Themes>
               <ComputerName>nt63</ComputerName>
           </component>
       </settings>
       <cpi:offlineImage
           cpi:source="wim:c:/sources/install.wim#Windows 8 Enterprise"
           xmlns:cpi="urn:schemas-microsoft-com:cpi" />
    </unattend>
    
    <?xml version="1.0" encoding="utf-8"?>
    <unattend xmlns="urn:schemas-microsoft-com:unattend">
       <settings pass="generalize">
           <component
               name="Microsoft-Windows-PnpSysprep"
               processorArchitecture="x86"
               publicKeyToken="31bf3856ad364e35"
               language="neutral" versionScope="nonSxS"
               xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
               <PersistAllDeviceInstalls>true</PersistAllDeviceInstalls>
           </component>
       </settings>
       <settings pass="specialize">
           <component
               name="Microsoft-Windows-Shell-Setup"
               processorArchitecture="x86"
               publicKeyToken="31bf3856ad364e35"
               language="neutral"
               versionScope="nonSxS"
               xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
               <Display>
                    <ColorDepth>32</ColorDepth>
                    <HorizontalResolution>1024</HorizontalResolution>
                    <VerticalResolution>768</VerticalResolution>
               </Display>
               <Themes>
                    <DefaultThemesOff>true</DefaultThemesOff>
                    <ScreenSaver>Off</ScreenSaver>
               </Themes>
               <ComputerName>win8ult32</ComputerName>
           </component>
       </settings>
       <cpi:offlineImage
           cpi:source="wim:c:/sources/install.wim#Windows 8 Enterprise"
           xmlns:cpi="urn:schemas-microsoft-com:cpi" />
    </unattend>
    
    <?xml version="1.0" encoding="utf-8"?>
    <unattend xmlns="urn:schemas-microsoft-com:unattend">
       <settings pass="generalize">
           <component
               name="Microsoft-Windows-PnpSysprep"
               processorArchitecture="amd64"
               publicKeyToken="31bf3856ad364e35"
               language="neutral"
               versionScope="nonSxS"
               xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
               <PersistAllDeviceInstalls>true</PersistAllDeviceInstalls>
           </component>
           <component
               name="Microsoft-Windows-Security-SPP"
               processorArchitecture="amd64"
               publicKeyToken="31bf3856ad364e35"
               language="neutral"
               versionScope="nonSxS"
               xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
               <SkipRearm>1</SkipRearm>
           </component>
       </settings>
       <settings pass="specialize">
           <component
               name="Microsoft-Windows-Shell-Setup"
               processorArchitecture="amd64"
               publicKeyToken="31bf3856ad364e35"
               language="neutral"
               versionScope="nonSxS"
               xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
               <Display>
                    <ColorDepth>32</ColorDepth>
                    <HorizontalResolution>1024</HorizontalResolution>
                    <VerticalResolution>768</VerticalResolution>
               </Display>
               <Themes>
                    <DefaultThemesOff>true</DefaultThemesOff>
                    <ScreenSaver>Off</ScreenSaver>
               </Themes>
               <ComputerName>w2k8r2ent</ComputerName>
           </component>
       </settings>
       <cpi:offlineImage
           cpi:source="wim:c:/sources/install.wim#Windows Server 2008 R2 SERVERENTERPRISE"
           xmlns:cpi="urn:schemas-microsoft-com:cpi" />
    </unattend>
    
    <?xml version="1.0" encoding="utf-8"?>
    <unattend xmlns="urn:schemas-microsoft-com:unattend">
       <settings pass="generalize">
           <component
               name="Microsoft-Windows-PnpSysprep"
               processorArchitecture="amd64"
               publicKeyToken="31bf3856ad364e35"
               language="neutral"
               versionScope="nonSxS"
               xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
               <PersistAllDeviceInstalls>true</PersistAllDeviceInstalls>
           </component>
       </settings>
       <settings pass="specialize">
           <component
               name="Microsoft-Windows-Shell-Setup"
               processorArchitecture="amd64"
               publicKeyToken="31bf3856ad364e35"
               language="neutral"
               versionScope="nonSxS"
               xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
               <Display>
                    <ColorDepth>32</ColorDepth>
                    <HorizontalResolution>1024</HorizontalResolution>
                    <VerticalResolution>768</VerticalResolution>
               </Display>
               <Themes>
                    <DefaultThemesOff>true</DefaultThemesOff>
                    <ScreenSaver>Off</ScreenSaver>
               </Themes>
               <ComputerName>win7ult64</ComputerName>
           </component>
       </settings>
       <cpi:offlineImage
           cpi:source="wim:c:/sources/install.wim#Windows 7 ULTIMATE"
           xmlns:cpi="urn:schemas-microsoft-com:cpi" />
    </unattend>
    
    <?xml version="1.0" encoding="utf-8"?>
    <unattend xmlns="urn:schemas-microsoft-com:unattend">
       <settings pass="generalize">
           <component
               name="Microsoft-Windows-PnpSysprep"
               processorArchitecture="x86"
               publicKeyToken="31bf3856ad364e35"
               language="neutral"
               versionScope="nonSxS"
               xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
               <PersistAllDeviceInstalls>true</PersistAllDeviceInstalls>
           </component>
       </settings>
       <settings pass="specialize">
           <component
               name="Microsoft-Windows-Shell-Setup"
               processorArchitecture="x86"
               publicKeyToken="31bf3856ad364e35"
               language="neutral"
               versionScope="nonSxS"
               xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
               <Display>
                    <ColorDepth>32</ColorDepth>
                    <HorizontalResolution>1024</HorizontalResolution>
                    <VerticalResolution>768</VerticalResolution>
               </Display>
               <Themes>
                    <DefaultThemesOff>true</DefaultThemesOff>
                    <ScreenSaver>Off</ScreenSaver>
               </Themes>
               <ComputerName>win7ult32</ComputerName>
           </component>
       </settings>
       <cpi:offlineImage
           cpi:source="wim:c:/sources/install.wim#Windows 7 ULTIMATE"
           xmlns:cpi="urn:schemas-microsoft-com:cpi" />
    </unattend>
    
    <?xml version="1.0" encoding="utf-8"?>
    <unattend xmlns="urn:schemas-microsoft-com:unattend">
       <settings pass="generalize">
           <component
               name="Microsoft-Windows-PnpSysprep"
               processorArchitecture="amd64"
               publicKeyToken="31bf3856ad364e35"
               language="neutral"
               versionScope="nonSxS"
               xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
               <PersistAllDeviceInstalls>true</PersistAllDeviceInstalls>
           </component>
       </settings>
       <settings pass="specialize">
           <component
               name="Microsoft-Windows-Shell-Setup"
               processorArchitecture="amd64"
               publicKeyToken="31bf3856ad364e35"
               language="neutral"
               versionScope="nonSxS"
               xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
               <Display>
                    <ColorDepth>32</ColorDepth>
                    <HorizontalResolution>1024</HorizontalResolution>
                    <VerticalResolution>768</VerticalResolution>
               </Display>
               <Themes>
                    <DefaultThemesOff>false</DefaultThemesOff>
                    <CustomDefaultThemeFile>
                         C:\Windows\Resources\Themes\Windows Classic.theme
                    </CustomDefaultThemeFile>
               </Themes>
               <ComputerName>vistault64</ComputerName>
           </component>
       </settings>
       <settings pass="oobeSystem">
           <component
               name="Microsoft-Windows-Sidebar"
               processorArchitecture="amd64"
               publicKeyToken="31bf3856ad364e35"
               language="neutral"
               versionScope="nonSxS"
               xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
               <SidebarOnByDefault>false</SidebarOnByDefault>
               <SidebarVisible>false</SidebarVisible>
           </component>
       </settings>
       <cpi:offlineImage
           cpi:source="wim:c:/sources/install.wim#Windows Vista ULTIMATE"
           xmlns:cpi="urn:schemas-microsoft-com:cpi" />
    </unattend>
    
    <?xml version="1.0" encoding="utf-8"?>
    <unattend xmlns="urn:schemas-microsoft-com:unattend">
       <settings pass="generalize">
           <component
               name="Microsoft-Windows-PnpSysprep"
               processorArchitecture="x86"
               publicKeyToken="31bf3856ad364e35"
               language="neutral"
               versionScope="nonSxS"
               xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
               <PersistAllDeviceInstalls>true</PersistAllDeviceInstalls>
           </component>
       </settings>
       <settings pass="specialize">
           <component
               name="Microsoft-Windows-Shell-Setup"
               processorArchitecture="x86"
               publicKeyToken="31bf3856ad364e35"
               language="neutral"
               versionScope="nonSxS"
               xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
               <Display>
                    <ColorDepth>32</ColorDepth>
                    <HorizontalResolution>1024</HorizontalResolution>
                    <VerticalResolution>768</VerticalResolution>
               </Display>
               <Themes>
                    <DefaultThemesOff>false</DefaultThemesOff>
                    <CustomDefaultThemeFile>
                         C:\Windows\Resources\Themes\Windows Classic.theme<
                    /CustomDefaultThemeFile>
               </Themes>
               <ComputerName>vistault32</ComputerName>
           </component>
       </settings>
       <settings pass="oobeSystem">
           <component
               name="Microsoft-Windows-Sidebar"
               processorArchitecture="x86"
               publicKeyToken="31bf3856ad364e35"
               language="neutral"
               versionScope="nonSxS"
               xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
               <SidebarOnByDefault>false</SidebarOnByDefault>
               <SidebarVisible>false</SidebarVisible>
           </component>
       </settings>
       <cpi:offlineImage
           cpi:source="wim:c:/sources/install.wim#Windows Vista ULTIMATE"
           xmlns:cpi="urn:schemas-microsoft-com:cpi" />
    </unattend>
    
  3. Change the ComputerName section to be the same as the hostname you’ve set in Kyndryl Cloud Uplift:

     <ComputerName>PUTYOURHOSTNAMEHERE</ComputerName>
    
  4. Save your VM as a template. This creates another backup copy that you can restore from later, if necessary.

Run Sysprep

  1. Click Start > Run and type the following command:

     c:\windows\system32\sysprep\sysprep /generalize /oobe /shutdown /unattend:c:\windows\system32\sysprep\unattend.xml
    
  2. When Sysprep is finished, your VM shuts down automatically,
  3. Save your VM as a template before powering the VM back up.

Test the master template

After running Sysprep and creating your new master template, create a new environment from the template and run the VM to test it:

  1. If you didn’t delete the user account during the Sysprep process, check that your password still works.
  2. Confirm that you have both mouse and keyboard control, and that the VM has networking connectivity. If you experience an issue, this might indicate a problem with the unattend file. Confirm that persistalldevices is included in the unattend file, and that the unattend file is in the right place.
  3. If you want to preserve the Windows activation grace period, check that the activation grace period has been reset. In most versions of Windows, you can find the grace period by right-clicking Computer and selecting Properties. If the grace period hasn’t been reset, remove the <skiprearm> line from the Sysprep unattend file.

Then, create a new environment and add two copies of the same VM to it for additional testing:

  1. Access the first VM. The OS should prompt you to complete an “out of the box” initial setup, including entering your country or region, entering the time zone, creating a new user password, and other initial user tasks. Repeat this process for the second VM. If the OS doesn’t prompt you to set up the second VM, confirm that /oobe is included in the sysprep command.
  2. After logging in for the first time, check to ensure the hostname within the guest OS matches what is set in Kyndryl Cloud Uplift; this can be done from the command line or within System Properties.

    If you adjusted the computer name in the Prepare to Sysprep section above, Kyndryl Cloud Uplift may initiate a reboot and rename the VM hostname to match what is set in Kyndryl Cloud Uplift. This may not happen for the first VM if the hostnames already match, but it will occur for all other VMs where the hostname in Kyndryl Cloud Uplift is different than the one defined in your answer file.

  3. Install PsGetSid on each VM in your environment. Ensure that the SID for each of the VMs in this environment are different; if the SID is the same for both images, make sure /generalize is included in the Sysprep command

    You can download PsGetSid as part of the PsTools package at http://technet.microsoft.com/en-us/sysinternals/bb897417.aspx. We recommend that you unzip this download and place it in your Kyndryl Cloud Uplift Assets page for easy access between all VMs.