Tuesday, 20 February 2018 08:50

Image Factory for VMware Workstation

Written by
Rate this item
(7 votes)


There are many reasons why an organization would spend a lot of time on image creation and maintenance. Often, it’s due to the lack of a standardized image engineering methodology. Whatever the cause, the experience of manually creating Windows images quickly deteriorates and becomes a time-consuming and difficult to manage organizational nightmare. However, using free Microsoft deployment tools and PowerShell you can greatly simplify the task of building and maintaining Windows images.

The good news is moving to an automated image creation is a far simpler task than one might assume, inverting the time you spend taking care of your image and the amount of time you spend driving innovation. Over the years, Mikael Nystrom put together a PowerShell-based solution called Reference Image Factory, which allows you to realize that future of fully automated image creation today. All you need is a Hyper-V enabled system and Microsoft Deployment Toolkit.

Imagine for a moment: you fire up a PowerShell script and a few hours later you get your shiny images. That's it. Simply put: the future of image creation is now. It is not a question of if but when and when is now. Pretty cool, right?

Unfortunately, there’s no one-size-fits-all solution as you need to consider the target platform and in some cases, Hyper-V is not the right hypervisor for the job. For example, a couple of months ago, I worked with a customer on implementing a Horizon Cloud DaaS with hosted infrastructure. When creating purpose-built OS images for VMware cloud platform you should use a VMware hypervisor (either VMware Workstation or ESXi will do) which makes it easy to deliver optimized, feature-rich, ready for deployment images.

If you are in the same boat as I am - first of all, I am sorry. Secondly, I did not want to deploy an ESXi host just for the sake of creating virtual machines templates for the hosted Horizon Cloud environment. Instead, I turned my attention towards VMware Workstation which is capable of exporting virtual machines in Open Virtual Format (OVF) format. You can then deploy the OVF template in the same or in a different environment.

So, I went ahead and modified Mikael's Reference Image Factory solution (remember, I am not a fan of reinventing the wheel) to work with Karsten Bott's excellent vmxtoolkit which allows you to control VMWare Workstation and virtually eliminates the technical requirements for manually creating Windows images for VMware environments. The resulting solution is available from my GitHub repository.


Steps involved:

  1. Download following PowerShell modules: PSINI (converts CustomSettings.ini file to a hashtable and back), vmxtoolkit (a Powershell extension for VMware Workstation), PSFTP (a PowerShell module which allows you to connect and manage the contents of an ftp account). Extract the modules into the pre-created folders.
  2. Install VMware Workstation as your virtualization host.
  3. Install and configure Microsoft Deployment Toolkit (MDT) build.
  4. Create your build & capture task sequences.
  5. Modify the accompanying XML file to match your environment.
  6. Run the script.

XML Settings:

Setting Description
TargetShare Determines where to store OVF files.
ConcurrentRunningVMs Determines how many VMs can run at the same time.
EnableFTP Switch to enable FTP upload.
FTPServer Hostname / IP of the target server.
FTPUsername Specifies a username with which to log on to the FTP server.
FTPPassword Specifies the password for FTPUserName.
FTPPath Specifies a subdirectory on the host server.
NoGui Enabling this option suppresses the user interface to allow non-interactive scripting.
EnableCleanup Determines if Image Factory destroys all VMs upon successful script execution.
DeploymentShare Specifies path for connecting to a deployment share.
Computername MDT server hostname.
RefTaskSequenceFolderName Task sequence folder containing your build & capture task sequences.
SkipCapture Specifies whenever or not to perform sysprep & capture.
StartUpRAM The amount of RAM per VM in GB.
VMLocation Location where the virtual machine configuration and virtual disks are stored.
ISOLocation Location where MDT boot images are being cached.
VHDSize Virtual disk size in GB.
NoCPU Number of vCPUs per VM.
ConnectionType Configures the network connection type for VMs.
AdapterType Selects the virtual network adapter type. vmxnet3 recommended for Horizon environments.
NumberOfMonitors Specifies the number of monitors.

Once you execute the script, it will run through the following steps:

The script will import external PS modules and parse the accompanying ImageFactory XML file containing configuration settings:

IMF32, Imagefactory 3.2 (VMware), 02/06/2018 09:03:54
IMF32, Logfile is C:\Setup\ImageFactoryForVMware\log.txt, 02/06/2018 09:03:54
IMF32, XMLfile is C:\Users\tolwyn\ImageFactory\ImageFactory.xml, 02/06/2018 09:03:54
IMF32, Importing modules, 02/06/2018 09:03:54
trying to get os type ... 
 ==>Product Name: Windows 
 ==>running vmxtoolkit for win_x86_64
==>vmrun is C:\Program Files (x86)\VMware\VMware Workstation\vmrun.exe
==>vmwarepath is C:\Program Files (x86)\VMware\VMware Workstation
==>virtual machine directory from module load is C:\Users\tolwyn\Documents\Virtual Machines\
==>default vmxdir is C:\Users\tolwyn\Documents\Virtual Machines\
==>running VMware Version Mode
==>OVFtool is C:\Program Files (x86)\VMware\VMware Workstation\OVFTool\ovftool.exe
==>Packertool is C:\Program Files (x86)\VMware\VMware Workstation\7za.exe
==>vdisk manager is C:\Program Files (x86)\VMware\VMware Workstation\vmware-vdiskmanager.exe
==>webrequest tool is .Net
==>isotool is C:\Program Files (x86)\VMware\VMware Workstation/mkisofs.exe
IMF32, Reading from C:\Users\tolwyn\ImageFactory\ImageFactory.xml, 02/06/2018 09:03:54

The script will then connect to your deployment share, determine and upload x86 and x64 boot images to the ISOLocation folder and will also enumerate all active TS in the RefTaskSequenceFolderName folder.

IMF32, Verify Connection to DeploymentRoot, 02/06/2018 09:03:54
IMF32, Verify Connection to OVF share, 02/06/2018 09:03:54
IMF32, Connect to MDT, 02/06/2018 09:03:54
IMF32, Get MDT Settings, 02/06/2018 09:03:54
IMF32, Check if we should update the boot image, 02/06/2018 09:03:54
IMF32, Check if we should use MDTmonitoring, 02/06/2018 09:03:54
IMF32, Verify access to x86 boot image, 02/06/2018 09:03:54
IMF32, Access to \\mdt01\VMwareCapture$\boot\vmware_lti_x86.iso is ok, 02/06/2018 09:03:54
IMF32, Verify access to x64 boot image, 02/06/2018 09:03:54
IMF32, Access to \\mdt01\VMwareCapture$\boot\vmware_lti_x64.iso is ok, 02/06/2018 09:03:54
IMF32, Get TaskSequences, 02/06/2018 09:03:54
IMF32, Found 4 TaskSequences to work on, 02/06/2018 09:03:54
IMF32, Get detailed info about the task sequences, 02/06/2018 09:03:54
IMF32, 10_1703_SYSPREP Windows 10 Enterprise 1703 1.0, 02/06/2018 09:03:54
IMF32, 10_1709_SYSPREP Windows 10 Enterprise 1709 1.0, 02/06/2018 09:03:54
IMF32, 7_X64_SYSPREP Windows 7 Professional x64 1.0, 02/06/2018 09:03:54
IMF32, 7_X86_SYSPREP Windows 7 Professional x86 1.0, 02/06/2018 09:03:54

Then, it will create a VM for each of the task sequences, apply HW configuration based on the settings you provided in the ImageFactory.xml file, inject a randomly generated MAC address and update CustomSettings.ini with that information. The MAC address is used to preselect a task sequence and run a fully unattended installation.

IMF32, Upload boot image to VMware host, 02/06/2018 09:03:54
IMF32, Create the VMs on Host, 02/06/2018 09:05:11
Working on 10_1703_SYSPREP
==>Creating new VM 10_1703_SYSPREP[success]
==>setting GuestOS windows8srv-64 for 10_1703_SYSPREP[success]
10_1703_SYSPREP is created
10_1703_SYSPREP HW version set to 11
Windows 10 x64 detected. Replacing guest OS type...
==>setting GuestOS windows9-64 for 10_1703_SYSPREP[success]
10_1703_SYSPREP RAM set to 2048 MB
==>creating new 60GB SCSI Disk 10_1703_SYSPREP at C:\Virtual Machines\vmxtoolkit\10_1703_SYSPREP[success]
C:\Virtual Machines\vmxtoolkit\10_1703_SYSPREP\10_1703_SYSPREP.vmdk is created for 10_1703_SYSPREP
==>adding Disk 10_1703_SYSPREP.vmdk at Controller 0 LUN 0 to 10_1703_SYSPREP[success]
C:\Virtual Machines\vmxtoolkit\10_1703_SYSPREP is attached to 10_1703_SYSPREP
10_1703_SYSPREP has 2 vCPU
WARNUNG: Adapter not present, will be added
==>configuring Ethernet0 as vmxnet3 with NAT for 10_1703_SYSPREP[success]
10_1703_SYSPREP is connected to vmxnet3 NAT interface
vmxnet3 NAT interface on 10_1703_SYSPREP configured to use static MAC address 02:4B:9A:1A:A0:6B
10_1703_SYSPREP configured to use 2 monitors
x64 OS detected.
==> Configuring IDE sata0:1 on 10_1703_SYSPREP[success]
C:\Virtual Machines\ISO\vmware_lti_x64.iso is attached to 10_1703_SYSPREP
10_1703_SYSPREP display name set to 10_1703_SYSPREP
Added REFIMAGE annotation to 10_1703_SYSPREP
IMF32, Update the CustomSettings.ini file, 02/06/2018 09:05:14

The script will then power up the VMs and wait until all OSDs are finished (depending on the number of task sequences and ConcurrentRunningVMs setting this may take a while). Next, the script will export the VMs into the OVF format suitable for import into vSphere. The script will remove any entries from CustomSettings.ini added during the initialization phase and, depending on your EnableCleanup setting, will also destroy all VMs.

Exporting 10_1703_SYSPREP to C:\Virtual Machines\OVF\20180206
Exporting 10_1709_SYSPREP to C:\Virtual Machines\OVF\20180206
Exporting 7_X64_SYSPREP to C:\Virtual Machines\OVF\20180206
Exporting 7_X86_SYSPREP to C:\Virtual Machines\OVF\20180206
IMF32, Update CustomSettings.ini, 02/06/2018 11:55:56
IMF32, Cleanup MDT Monitoring data, 02/06/2018 11:55:57
IMF32, Show the OVFs, 02/06/2018 11:55:57
IMF32, OVF: C:\Virtual Machines\OVF\20180206\10_1703_SYSPREP\10_1703_SYSPREP.ovf, 02/06/2018 11:55:57
IMF32, OVF: C:\Virtual Machines\OVF\20180206\10_1709_SYSPREP\10_1709_SYSPREP.ovf, 02/06/2018 11:55:57
IMF32, OVF: C:\Virtual Machines\OVF\20180206\7_X64_SYSPREP\7_X64_SYSPREP.ovf, 02/06/2018 11:55:57
IMF32, OVF: C:\Virtual Machines\OVF\20180206\7_X86_SYSPREP\7_X86_SYSPREP.ovf, 02/06/2018 11:55:57
IMF32, The script took 0:Days 2:Hours 52:Minutes to complete., 02/06/2018 11:55:57


Today is one of the most exciting time in terms of technology and how it intervenes with our daily life. I strongly recommend embracing automation for image creation process due to the new way that Microsoft introduced to build, deploy, and service Windows: Windows as a Service. Windows 10 needs to be upgraded in a more frequent manner. By speaking of more frequently - you will need to deploy a new version of Windows every year, or optimally twice per year which is what I recommend for businesses in order to benefit from the new way Microsoft is building the OS in a long-term scope. This also implies that you will need to create new Windows 10 images on a regular basis.

The utopia of "click-and-go" image creation process that’s easy to maintain is here. Even better, all you need are free tools from Microsoft and one VMware Workstation license. By taking advantage of automation and by eliminating the drudgery of maintaining the machinery, you will reap rewards for many years to come

Read 12846 times Last modified on Thursday, 22 February 2018 08:34

Recent Posts

  • Windows 10 21H2 Built-In Apps: What to Keep
    The development of the Windows 10, version 21H2 is finished and the update will soon be available for download from…
    Written on Wednesday, 20 October 2021 11:41
  • Group Policy Changes in Windows 10 21H2
    As Windows 10, version 21H2 update development winds down, Microsoft is now preparing for the final release of the Windows…
    Written on Wednesday, 20 October 2021 07:20
  • Group Policy Changes in Windows 10 20H1 Preview
    As Windows 10 Vibranium Update (20H1) development winds down, Microsoft is now beginning the phase of checking in the final…
    Written on Tuesday, 14 January 2020 04:51
  • An alternative ESU MAK Activation Solution
    This blog post was shared with me by a colleague of mine, Daniel Dorner, a Microsoft Premier Field Engineer. It’s…
    Written on Wednesday, 04 December 2019 21:04
  • The Case of Missing UE-V Templates
    My customers often deal with unexpected Windows behavior and this case is no different. This particular one is especially interesting…
    Written on Tuesday, 03 September 2019 12:20
  • The Case of Changing Default Printer
    While I sometimes long for the day when I no longer have to deal with unexpected Windows 10 behavior, there’s…
    Written on Wednesday, 14 August 2019 20:36