With the release of PowerCLI 13, VMware has introduced some major enhancements. One of the most exciting features is that PowerCLI is now fully Multi-platform, which means that all functions are available for all PowerShell Core supported operating systems including Windows, macOS, and Linux. If you are planning to use the ImageBuilder module, you will need to have Python 3.7 installed on your machine.
If you want to use ImageBuilder-based commands in PowerCLI 13, you might see the following error:
Add-EsxSoftwareDepot: Could not initialize the VMware.ImageBuilder PowerCLI module. Make sure that Python 3.7 is installed and that you have set the path to the Python executable by using Set-PowerCLIConfiguration -PythonPath. See the PowerCLI Compatibility Matrixes for information on the Python requirements.
This article explains how to install and configure PowerCLI 13 with Python 3.7 to be ready to use ImageBuilder.
Step 1 - Install PowerCLI
The simplest way to install PowerCLI is by using the packages provides in Microsofts PowerShell Gallery: PowerShell Gallery | PowerCLI 13
PS> Install-Module -Name VMware.PowerCLI
Step 2 - Install Python
Go to www.python.org/downloads/release/python-379/ and download the executable installer. This will install python 3.7.9, which is currently the latest version where binaries are available.
You should note the path where Python is installed. If you did not note it during the installation wizard you can find it out later with the where command:
C:\> where python C:\Users\[USERNAME]\AppData\Local\Programs\Python\Python37\python.exe
Also, make sure that the python path is added to your PATH variables and you can run python from everywhere.
c:\> python --version Python 3.7.9
Step 3 - Install PIP and Modules
PIP is Python's own packet manager which is required to install additional modules.
Download bootstrap.pypa.io/get-pip.py and run it with python.
c:\> python.exe .\get-pip.py Collecting pip Successfully installed pip-22.3.1
Now install modules six, psutil, lxml, and pyopenssl, which are required by PowerCLI.
c:\> pip3.7.exe install six psutil lxml pyopenssl
Step 4 - Open PowerShell and Configure PythonPath
If you've installed Python in your userspace you should be able to set PythonPath with the following command:
PS> Set-PowerCLIConfiguration -PythonPath $env:USERPROFILE\AppData\Local\Programs\Python\Python37\python.exe -Scope User
Now you should be able to use PowerCLI ImageBuilder.
Example to create ESXi 8 Image with the USB NIC Fling.
Add-EsxSoftwareDepot .\VMware-ESXi-8.0a-20842819-depot.zip Add-EsxSoftwareDepot .\ESXi800-VMKUSB-NIC-FLING-61054763-component-20826251.zip New-EsxImageProfile -CloneProfile "ESXi-8.0a-20842819-standard" -name "ESXi-8.0a-20842819-USBNIC" -Vendor "virten.net" Add-EsxSoftwarePackage -ImageProfile "ESXi-8.0a-20842819-USBNIC" -SoftwarePackage "vmkusb-nic-fling" Export-ESXImageProfile -ImageProfile "ESXi-8.0a-20842819-USBNIC" -ExportToIso -filepath ESXi-8.0a-USBNIC.iso Export-ESXImageProfile -ImageProfile "ESXi-8.0a-20842819-USBNIC" -ExportToBundle -filepath ESXi-8.0a-USBNIC.zip