VMware PowerCLI is very handy and flexible automation tool allowing automation of almost all VMware features. It is based on Microsoft PowerShell. I do not have any Microsoft Windows system in my home lab but I would like to use Microsoft PowerShell. Fortunately enough, Microsoft PowerShell Core is available for Linux. Here is my latest runbook how to leverage PowerCLI in Linux management workstation leveraging Docker Application packaging.
Install Docker in your Linux Workstation
This is out of scope of this runbook.
Pull official and verified Microsoft Powershell
sudo docker pull mcr.microsoft.com/powershell:latest
Now you can run powershell container interactively (-i) and in allocated pseudo-TTY (-t). Option -rm stands for "Automatically remove the container when it exits".
List container images
sudo docker image ls
Run powershell container
sudo docker run --rm -it mcr.microsoft.com/powershell
You can avoid image pull and run powershell container, it will pull image automatically during first attempt of run.
Install PowerCLI in PowerShell
Install-Module -Name VMware.PowerCLI -Scope CurrentUser -Force
Allow Untrusted Certificates
Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false
Now you can connect to vCenter and list VMs
Connect-VIServer -Server <vcenter-server> -User <username> -Password <password>
Get-VM
No comments:
Post a Comment