When deploying multiple VMware ESXi hosts, creating customized installation ISOs with the correct Kickstart configuration for each host quickly becomes tedious. Manually editing boot.cfg, copying files, and rebuilding ISOs for every host is time-consuming and error-prone.
This PowerShell script automates the entire process. It takes a standard ESXi installation image, injects the correct Kickstart settings for each host, and generates ready-to-use ISO files — all from a single configuration.
The script is available at https://github.com/ArrowECS-Niclas/Create-ESXi-ISO-files-using-WSL
Purpose of the script
The script is designed for environments where you need to deploy several ESXi hosts (for example ESX01, ESX02, ESX03) with host-specific Kickstart files.
It solves several common problems:
- Automatically updates kernelopt in both BIOS and UEFI boot configuration files
- Supports different installation media types (network/http, USB, or CD/DVD)
- Downloads the correct KS.CFG when needed
- Builds properly bootable hybrid ISOs (BIOS + UEFI)
- Names the resulting ISO files with the ESXi build number for easy identification
Key Features
- Automatic version detection – Reads the build= value from boot.cfg
- Host-specific Kickstart injection – Updates kernelopt for each host
- Multiple media types:
- http → Points to a network Kickstart URL
- USB → Embeds KS.CFG and sets ks=usb:/KS.CFG
- CD → Embeds KS.CFG and sets ks=cdrom:/KS.CFG
- Import from existing ISO – If the binaries folder is empty, the script can mount an official ESXi ISO and extract the files
- WSL + genisoimage – Creates standards-compliant hybrid ISOs
- Automatic cleanup – Removes temporary KS.CFG files after each ISO is created
- Robust error handling – Clear messages if WSL, genisoimage, or boot files are missing
Prerequisites
- Windows 10/11 or Windows Server with PowerShell 5.1+
- WSL installed with an Ubuntu distribution
- genisoimage (the script can install it automatically)
- An official VMware ESXi ISO (used as the source)
Configuration
All important settings are located at the top of the script:
PowerShell
$BinariesDir = "C:\ESXi9"
$IsoOutDir = "C:\ISO_images"
$WslDistro = "Ubuntu"
$WslUserHome = "/home/username"
$KickstartBaseUrl = "http://192.168.0.76/kickstart/"
$MediaType = "http" # http | USB | CD
$HostConfigDir = @("ESX01", "ESX02", "ESX03")
Each host will have a unique KS.CFG file in
http://192.168.0.76/kickstart/ESX01/KS.CFG
http://192.168.0.76/kickstart/ESX02/KS.CFG
http://192.168.0.76/kickstart/ESX03/KS.CFG
Which will be the source either read from the webserver during installation or to be copied from the webserver when creating a USB or CD image.
| Variable | Description |
|---|---|
| $BinariesDir | Working directory containing the ESXi files |
| $IsoOutDir | Destination folder for the finished ISO files |
| $KickstartBaseUrl | Base URL for kickstartfiles |
| $MediaType | Installation method (http, USB, or CD) |
| $HostConfigDir | List of hosts to generate ISOs for |
Example KS.CFG File
Below is a realistic example of a Kickstart file (KS.CFG) that can be used with the script. Each host would normally have its own slightly modified version (different hostname, IP address, etc.).
Bash
#
# Sample ESXi Kickstart file (KS.CFG)
# Compatible with ESXi 7.x / 8.x / 9.x
#
# Accept the EULA
vmaccepteula
# Set root password (change this!)
rootpw MyStr0ngP@ssw0rd
# Install on the first available local disk
# Warning: This will clear the disk
install --firstdisk --overwritevmfs
# Network configuration
network --bootproto=static --ip=192.168.0.101 --netmask=255.255.255.0 --gateway=192.168.0.1 --nameserver=192.168.0.1 --hostname=ESXi01.lab.local --addvmportgroup=0
# Reboot after installation
reboot
# First boot script (runs once after installation)
%firstboot --interpreter=busybox
# Enable SSH
vim-cmd hostsvc/enable_ssh
vim-cmd hostsvc/start_ssh
# Enable ESXi Shell
vim-cmd hostsvc/enable_esx_shell
vim-cmd hostsvc/start_esx_shell
# Suppress the shell warning in the DCUI
esxcli system settings advanced set -o /UserVars/SuppressShellWarning -i 1
# Optional: Set NTP
esxcli system ntp set --server=pool.ntp.org
esxcli system ntp set --enabled=true
echo "Firstboot configuration completed" >> /var/log/firstboot.log
%end
Notes about the Kickstart file:
- Change the rootpw, IP address, hostname and disk selection according to your environment.
- When using MediaType = http, place one KS.CFG per host under the web server path, for example:
- http://192.168.0.76/kickstart/ESXi01/KS.CFG
- http://192.168.0.76/kickstart/ESXi02/KS.CFG
- When using USB or CD mode, the script automatically downloads the correct KS.CFG and embeds it in the ISO.
How to Use the Script
- Prepare the source files
- Either copy the contents of an official ESXi ISO into $BinariesDir, or
- Leave $BinariesDir empty — the script will ask if you want to import from an ISO.
- Edit the configuration section
- Set the correct paths
- Choose the desired $MediaType
- Update the list of hosts in $HostConfigDir
- Run the scriptPowerShell
.\Create-EsxiIsos.ps1 - Result
The script will generate one ISO per host, for example:- ESX01-9.1.1-0.25714478.iso
- ESX02-9.1.1-0.25714478.iso
- ESX03-9.1.1-0.25714478.iso
Media Type Behavior
| MediaType | What the script does |
|---|---|
| http | Only updates kernelopt to point to the network Kickstart URL. No KS.CFG is embedded. |
| USB | Downloads the host-specific KS.CFG, places it in the root of the ISO, and sets kernelopt=ks=usb:/KS.CFG |
| CD | Same as USB, but sets kernelopt=ks=cdrom:/KS.CFG |
After each ISO is created, the temporary KS.CFG is removed so it does not affect the next host.
Typical Workflow
- Script checks that WSL and genisoimage are available
- (Optional) Imports files from an official ESXi ISO if the working directory is empty
- Detects the ESXi build number from boot.cfg
- For each host:
- Updates boot.cfg and efi\boot\boot.cfg
- Downloads KS.CFG if needed (USB/CD mode)
- Builds a hybrid ISO with genisoimage
- Cleans up temporary files
- Moves all finished ISOs to the output directory
Summary
This script turns a repetitive and error-prone manual process into a repeatable, one-command operation. Whether you prefer network-based Kickstart or fully offline USB/CD installations, it gives you consistent, correctly configured ESXi ISOs for every host in your environment.
Ideal for homelabs, edge deployments, or any situation where you need to roll out multiple identically prepared but host-specific ESXi installers.









You must be logged in to post a comment.