HOWTO: Create a Custom VMware vSphere 6.x ESXi Image using PowerCLI

Share this on:

VMware PowerCLI vSphere ESXi

Published on 12 April 2016 by Christopher Lewis. Words: 464. Reading Time: 3 mins.

As part of the continual (re)deployment and evolution of my home lab I have created a custom ESXi image to include a VIB for my Synology SAN. Whilst I will concentrate on the steps required to complete this specifically for the Synology, the principle applies to any home lab or indeed any Production environment that needs a custom VMware vSphere ESXi Image.

Required Software:

  • VMware PowerCLI (latest available)
  • VMware vSphere offline bundle downloadable from VMware (I’m using the 6.0U2 bundle)
  • Synology NFS (ZIP) downloadable from Synology (I have the DS1815+)

I try to be structured when it comes to scripting and this sort of thing, so I have create a folder structure which I will share, therefore the 22 Note: I use Windows 10, so if you use another variant or Mac OS the steps maybe subtly different.

Steps for creating a New Custom ESXi Image

Open PowerCLI

Go to the folder containing the downloaded ZIP/VIBs, in my instance this is the ESX folder using cd c:\homelab\esx

Mount the VMware vSphere ESXi 6 Offline bundle and additional VIBs (in this instance the Synology NFS VAAI) using the Add-EsxSoftwareDepot command:


Create a new ESX Image Profile by cloning the existing standard image using the New-EsxImageProfile command

New-EsxImageProfile -CloneProfile ESXi-6.0.0-20160302001-standard -Name <insert new image name> -Vendor Custom

Add the extra software package(s) (in this instance the Synology NFS VAAI Plug-In) using Add-EsxSoftwarePackage command:

Add-EsxSoftwarePackage -ImageProfile <new image profile> -softwarepackage esx-nfsplugin

Create the new VMware vSphere 6 ISO image using the Export-EsxImageProfile command:

Export-EsxImageProfile -ImageProfile <new image profile> -FilePath vsphere.iso ExportToIso

You can now use the created ISO to build you VMware vSphere ESXi Host Servers.

Full PowerCLI Script

The above steps can be scripted in one Powershell/Power CLI script as follows:

$WorkingFolder = "C:\homelab\esx"
$VMwareOfflineZip = "$WorkingFolder\"
$SynologyZip = "$WorkingFolder\"
$NewProfile = "ESXi-6.0.0-20160405"
$NewISO = "$WorkingFolder\vSphere6-Custom.iso"
Write-Host "Adding ImageBuilder Modules" -ForegroundColor Green
Add-PSSnapin Vmware.ImageBuilder -ErrorAction SilentlyContinue
#Get-EsxImageProfile -Name $NewProfile | Remove-EsxImageProfile -ErrorAction SilentlyContinue
Write-Host "Adding VMware Offline Bundle to Software Depot" -ForegroundColor Green
Add-EsxSoftwareDepot $VMwareOfflineZip
Write-Host "Adding Synology NFS VAAI Offline Bundle to Software Depot" -ForegroundColor Green
Add-EsxSoftwareDepot $SynologyZip
Write-Host "Cloning VMware vSphere 6 Image Profile and adding the Synology NFS VAAI Plugin" -ForegroundColor Green
New-EsxImageProfile -CloneProfile ESXi-6.0.0-20160302001-standard -Name $NewProfile -Vendor Custom
Add-EsxSoftwarePackage -ImageProfile $NewProfile -SoftwarePackage esx-nfsplugin
Write-Host "Creating vSphere 6 ISO " -ForegroundColor Green
Export-EsxImageProfile -ImageProfile $NewProfile -FilePath $NewISO ExportToIso

Which gives the following output within the PowerCLI console:

_Note: As part of the PowerCLI session, If you have already created a custom image with the name you want to use (i.e. you have created a new image and decided to add some more custom VIBs to it), you can see the Get-EsxImageProfile cmdlet to view current image profiles.

And you will need to remove it first by running **Remove-EsxImageProfile -ImageProfile

Published on 12 April 2016 by Christopher Lewis. Words: 464. Reading Time: 3 mins.