I received a question from Andrea Peetz, asking whether the new Image Builder cmdlets, which is part of the new PowerCLI 13.0 release would work with Photon OS 3.0 (PH3)? After speaking with the PowerCLI team, it looks like Photon OS 3.0 is not compatible with the new cmdlets. If you attempt to use one of the Image Builder cmdlets like Get-EsxSoftwareDepot, you will get the following error:
Unable to cast object of type 'System.IO.FileStream' to type 'System.IO.Pipes.PipeStream'.
While I have not used PH3 for quite some time now, I do use Photon OS 4.0 (PH4) on a regular basis. I was curious if I would have better luck with the new Image Builder cmdlets. Unlike PH3 which ships with Python 3.7, which is the required version for the Image Builder cmdlets, PH4 ships with a newer version of Python which is 3.10 and will not work with PowerCLI. We can still meet this requirement, but we will need to install Python via pyenv.
After a quick test, I was able to get the basic Image Builder cmdlets working and while going through a complete end-to-end workflow to make sure everything was working, I ran into a slightly different issue. When using the Export-EsxImageProfile cmdlet to export an ESXi Image Profile to an ISO file, I got the following error:
Can not instantiate 'certified' policy: VibSign module missing.
Quickly debugging the issue with the PowerCLI team, it looks like the VibSign module that has been compiled has a dependency on OpenSSL 1.1 and PH4 ships with OpenSSL 3.0 by default. Luckily, I was able to find a workaround by building the required file from the latest stable OpenSSL 1.1 release. Once the dependency was fulfilled, I was able successfully complete the Image Builder workflow!
Similiar to PH3, if you do not require the use of the Image Builder cmdlets, PowerCLI 13.0 can be installed on PH4 using the instructions below. If you do need to use the Image Builder cmdlets on PH4, you will need to run Step 2 below as that is a required step. I have also reported both of these issues with the PowerCLI team.
Step 1 - Install Photon OS 4.0 and run the following commands to install the required packages:
tdnf -y update
tdnf -y install wget tar git patch build-essential gcc zlib-devel openssl-devel powershell
Step 2 - Download and compile the latest stable OpenSSL 1.1 release (1.1.1.s is latest version as of this blog post) and copy the shared library file to /usr/lib directory by running the following commands:
tar -zxvf openssl-1.1.1s.tar.gz
cp libcrypto.so.1.1 /usr/lib
Step 3 - Next, we need to setup pyenv to install the specific Python version that PowerCLI 13.0 supports which is 3.7.x. Clone the pyenv github repo and setup the required paths by running the following commands:
git clone https://github.com/pyenv/pyenv.git ~/.pyenv
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile
echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.bash_profile
Step 4 - Install Python 3.7 and the required Python packages by running the following commands:
pyenv install 3.7
pyenv global 3.7.16
pip3 install six psutil lxml pyopenssl
Step 5 - Lastly, launch PowerShell and install PowerCLI by running the following commands:
Set-PowerCLIConfiguration -PythonPath /root/.pyenv/shims/python3.7