Part of my job responsibilities are managing a large VMware installation and a tool which I use frequently, is PowerShell with the VMware modules. The following is only how I installed it on macOS and is by far not the only way.
First, I use Brew, it just makes things easier for me to get all the tools that I require and keep them up to date easily. Click here if you could like to know how to install Brew.
Installing PowerShell via Brew
Installing PowerShell via Brew is very easy and can be done via a simple command:
brew cask install powershell
Once this is complete you can access PowerShell in one of two different ways. The first is once the installation is complete you’ll have a PowerShell icon in your applications folder. However, the easier way to access PowerShell will be via Terminal and typing:
Installing VMware modules into PowerShell
Next we will install the VMware modules, which is why we’re putting sudo in front so that we’re working as an Administrator.
sudo pwsh Find-Module -Name VMware.PowerCLI Install-Module -Name VMware.PowerCLI -Scope CurrentUser
Now let’s verify that everything got installed
Get-Command -Module *VMWare*
If everything went as expected you’ll see a long list of VMware modules.
Connecting to your vCenter
Connect-VIServer -Server vcenter.host.local -User firstname.lastname@example.org -Password
So, now what?
For more detailed documentation that what’s found here, click this link.
To get a list of all your virtual machines:
If you want to see a lot more information about each machine you can have that information spit out in a nice format list, like this:
get-vm | fl
A common task is moving virtual machines from here to there as users believe that memory and CPU are infinite. The following command would move the VM to the new ESXi host, via vMotion:
Move-VM -VM 'vmname' -Destination 'newesxi host'
The point of this post was to get everyone up and running on macOS with PowerShell and VMware. There are many resources on-line that will help you continue your journey.