This page looks best with JavaScript enabled

Image Factory Utility

Automate Creation of WIM Files

Image Factory Utility can also be downloaded from:

A demonstration video is available on my YouTube channel.

If you would like to support me, please check out the links below. Thank you!

If you’d like to contact me, please leave a comment, send me a tweet, or you can join the community on Discord.


Features and Requirements

  • This utility is designed to run on a computer with Microsoft Deployment Toolkit installed.
  • The computer must have either the Hyper-V management PowerShell modules installed, or Oracle Virtual Box.
  • The primary function of this utility is to automate the production of WIM files from MDT task sequences.
  • The utility requires at least PowerShell 5.0.
  • This utility has been tested on Windows 11, Windows 10, Windows Server 2019, Windows Server 2016 and Windows Server 2012 R2.

Oracle Virtual Box

This utility expects Oracle Virtual Box to be installed in the default location of: C:\Program Files\Oracle\VirtualBox

Important Information

The utility will make changes to your customsettings.ini file, although it will make a backup first. These changes are necessary so that the build process runs automated. Depending on your environment, you may need to make additional changes to your customsettings.ini.

Separating your build and deployment shares

I would recommend running with a separate build share so that:

  • The Image Factory Utility doesn’t tie up the main deployment share whilst running.
  • The build environment can be configured separately.
  • The boot media for the build share can be configured to automatically log into the deployment environment.

Here are the settings you’ll need to add to your Bootstrap.ini to automatically log into the build share. Don’t forget to update your build share in MDT and regenerate the boot images.



Generating A Password File

The password used for SMTP server authentication must be in an encrypted text file. To generate the password file, run the following command in PowerShell on the computer and logged in with the user that will be running the utility. When you run the command, you will be prompted for a username and password. Enter the username and password you want to use to authenticate to your SMTP server.

Please note: This is only required if you need to authenticate to the SMTP server when send the log via e-mail.

$creds = Get-Credential
$creds.Password | ConvertFrom-SecureString | Set-Content c:\scripts\ps-script-pwd.txt

After running the commands, you will have a text file containing the encrypted password. When configuring the -Pwd switch enter the path and file name of this file.


Here’s a list of all the command line switches and example configurations.

Command Line Switch Description Example
-Build Location of the build share. It can be the same as the deployment share, and it can be a local or UNC path. \\server\buildshare$ OR C:\BuildShare
-Deploy Location of the deployment share. It can be the same as the deployment share, and it can be a local or UNC path. \\server\deploymentshare$ OR C:\DeploymentShare
-Vh Hyper-V Only - Name of the Hyper-V host if remote. If not set it will default to local. VS01
-Vhd The path to store the virtual hard disk file(s). If using a remote Hyper-V server the path should be relative for that server. C:\VMs\VHD
-Boot The path to the ISO file to boot from. If using a remote Hyper-V server the path should be relative for that server. C:\iso\LiteTouchPE_x64.iso
-Vnic Hyper-V Only - Name of the virtual switch that the VM should use to communicate with the network. If the name of the switch contains a space encapsulate with single or double quotes. vSwitch-Ext
-Ts The comma-separated list of task sequence ID’s to build. W11-21H2,W10-21H2,WS22-DC
-VBox Use this switch to use Oracle Virtual Box instead of Hyper-V N/A
-Compat Legacy Hyper-V Only - Use this switch if the Hyper-V host is Windows Server 2012 R2 and the script is running on Windows 10 or Windows Server 2016/2019. This loads the older version of the Hyper-V module, so it can manage WS2012 R2 Hyper-V VMs. N/A
-Remote Hyper-V Only - Use this switch if the Hyper-V server is a remote device. N/A
-NoBanner Use this option to hide the ASCII art title in the console. N/A
-L The path to output the log file to. The file name will be Image-Factory_YYYY-MM-dd_HH-mm-ss.log. Do not add a trailing \ backslash. C:\scripts\logs
-Subject The subject line for the e-mail log. Encapsulate with single or double quotes. If no subject is specified, the default of “Image Factory Utility Log” will be used. ‘Server: Notification’
-SendTo The e-mail address the log should be sent to.
-From The e-mail address the log should be sent from.
-Smtp The DNS name or IP address of the SMTP server. OR
-Port The Port that should be used for the SMTP server. If none is specified then the default of 25 will be used. 587
-User The user account to authenticate to the SMTP server.
-Pwd The txt file containing the encrypted password for SMTP authentication. C:\scripts\ps-script-pwd.txt
-UseSsl Configures the utility to connect to the SMTP server using SSL. N/A


Image-Factory.ps1 -Build \\mdt01\BuildShare$ -Deploy \\mdt01\DeploymentShare$ -Vh VS01 -VHD C:\Hyper-V\VHD -Boot C:\iso\LiteTouchPE_x64.iso -Vnic vSwitch-Ext -Remote -Ts W11-21H2,W10-21H2,WS22-DC -L C:\scripts\logs -Subject 'Server: Image Factory' -SendTo -From -Smtp -User -Pwd c:\scripts\ps-script-pwd.txt -UseSsl

The above command will build WIM files from the task sequences W11-21H2, W10-21H2 and WS22-DC. They will be imported to the deployment share on MDT01. The Hyper-V host used will be VS01 and the VHDs for the VMs generated will be stored in C:\Hyper-V\VHD on the host. The boot ISO file will be C:\iso\LiteTouchPE_x64.iso, also located on the Hyper-V host. The virtual switch used by the VMs will be called vSwitch-Ext. The log file will be output to C:\scripts\logs and e-mailed with a custom subject line.

Change Log

2021-12-02: Version 21.12.01

  • Added option to use Oracle Virtual Box instead of Hyper-V.
  • Configured logs path now is created, if it does not exist.
  • Added OS version info.
  • Added an option to specify the Port for SMTP communication.

2021-06-22: Version 21.06.22

  • Added a progression bar display.
  • Changed a variable to prevent conflicts with future PowerShell versions.

2020-02-27: Version 20.02.24 ‘Robot’

New features:

  • Refactored code.
  • Fully backwards compatible.
  • Added ASCII banner art when run in the console.
  • Added option to disable the ASCII banner art.

2019-09-04 v2.9

  • Added custom subject line for e-mail.

2018-12-17 v2.8

  • The script will now set automatic checkpoints to ‘disabled’ on the VM’s. This is to help with VM disk management and clean up.

2017-10-16 v2.7

  • Changed SMTP authentication to require an encrypted password file.
  • Added instructions on how to generate an encrypted password file.

2017-10-09 v2.6

  • Added necessary information to add the script to the PowerShell Gallery.

2017-09-18 v2.5

  • Added a sanity check of the MDT deployment share. The script now checks for an existing CustomSettings-backup.ini file. If it exists, it reports that the deployment share is not clean.
  • Added extra line breaks when editing the CustomSettings.ini as previously it was adding the required configuration on the last line of the ini file and causing the deployment to fail. Many thanks to Twitter user @thestardawg for reporting this bug.

2017-08-26 v2.4

  • Improved logging so that the log file and console output is now more readable.

2017-07-22 v2.3

  • Improved commenting on the code for documentation purposes.
  • Added authentication and SSL options for e-mail notification.

2017-05-11 v2.2

  • Added command line configuration options so the script itself does not need to be edited.
  • Added code to manage the Virtual Machines without the need for extra configuration options.
  • Removed some unnecessary extra configuration options and variables.

2017-04-25 v2.1

I’ve added logging to the script and the ability to email the log on completion. I’ve also added a variable to configure the Virtual Switch that the VM’s Network Adaptor should use. This was an oversight on the previous version.

2017-04-17 Minor update

I’ve added hour and minutes to the WIM file creation name as I have been running multiple images of the same Task Sequence within a day and needed some extra data to prevent the image from over writing the previous one. I’ve also made another script, using this one as a base so I can generate VMs to test the deployment of the captured images after I’ve manually renamed them in MDT and added to the task sequences. The VMs are named after the Task Sequence ID and do not delete after the Task Sequence completes.

Share on
Support the author with