PowerCLI 13.0 was just released about a week ago and I have been using it like crazy, especially with the new Image Builder and Auto Deploy cmdlets, which have now been ported over to PowerShell Core and finally removing the Windows-only dependency for these specific cmdlets! 😀
I have both an x86 macOS system and the new Apple Silicon M1 (Arm) and of course, I wanted to have PowerCLI running on both systems! While the installation/upgrade of PowerCLI for x86 is trivial, it was definitely less so on the M1. Part of the challenge is also due to the new requirement with latest PowerCLI 13.0 release, which folks should be aware of as it does have additional implications in how you manage and deploy PowerCLI within your organizations.
PowerCLI 13.0 now has an external dependency on Python 3.7.x runtime, which is specific when needing to use the new Image Builder and Auto Deploy cmdlets. The official PowerCLI User Guide contains instructions on how to install the Python runtime and the required packages across the three OS platforms (Windows, macOS and Linux). While the external dependency of Python is new, the requirement for Python to use these cmdlets has always been there and earlier releases of PowerCLI, it was just packaged as part of PowerCLI.
I only bring up this detail because it ultimately helped me figure out how to get PowerCLI 13.0 working on the Apple M1, especially with the additional Python requirement which includes one specific shared library that is dependent on the x86 architecture.
Step 1 - Open Terminal and install Rosetta, which is a utility that Apple provides to run x86 binaries on the Apple Silicon.
softwareupdate --install-rosetta --agree-to-license
Step 2 - Install the x86 version of Brew, which will be required to then install the x86 version of Python by running the following command:
arch --x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Note: The use of the arch command to install x86 version brew was thanks to this StackOverflow answer.
Step 3 - The x86 version of brew will be located under /usr/local/bin and run the following command to install Python 3.7:
arch --x86_64 /usr/local/bin/brew install [email protected]
Step 4 - Next, we will install the required Python packages as outlined in the PowerCLI User Guide using pip by running the following command:
arch --x86_64 /usr/local/bin/pip3.7 install six psutil lxml pyopenssl
Step 5 - Install PowerShell, which can be done through Arm version of brew or if you do not have that, then provide fully path to x86 version of brew:
brew install --cask powershell
Note: I would recommend using the Arm version of brew since PowerShell for Arm is natively supported by Microsoft. For detailed instructions, please refer to official Microsoft documentation.
Step 6 - Now, we can launch PowerShell by running the following command:
Step 7 - Install the latest PowerCLI release by running the following command:
Step 8 - Finally, we need to configure the Python path so that PowerCLI knows where to look for the Python runtime by running the following command:
Set-PowerCLIConfiguration -PythonPath /usr/local/bin/python3.7
At this point you are now ready to start using PowerCLI 13.0 and the Image Builder and Auto Deploy cmdlets on an Apple M1!
For those interested in the "x86" details I mentioned above, I initially had PowerCLI 13.0 and 99% of the Image Builder cmdlets working on Apple Silicon just by simply installing Python 3.7 via pyenv for Arm and then the four required Python packages, I thought this was a piece of cake! The issue that I ran into while testing PowerCLI was when attempting to use the Export-EsxImageProfile cmdlet to export to an ISO, I hit the following error:
Export-EsxImageProfile: Can not instantiate 'certified' policy: VibSign module missing.
I came to learn that this cmdlet depends on a shared library that was compiled only for x86 and hence why the steps above were needed to basically have an x86 Python runtime to be able to use this cmdlet. If you do not need to use this specific cmdlet, then you can just install PowerShell for Arm and then install PowerCLI 13.0 on top as it just requires PowerShell Core. I I have already shared this with the PowerCLI Engineering team and this is something they will improve in future for better Apple Silicon support. For now, these are the steps if you want to use these specific PowerCLI cmdlets on an Apple Silicon system.