Here is the info I used to get PowerShell and PowerCLI working on my Mac. While it is here for the next time I need it, it is also here in case I helps you. And it was weird. Very weird – as I had to clean up.
We are doing PowerShell 6.0.1 Core and PowerCLI 10.0 on the Mac. If you want to do the same on Centos here is a very good article.
Lets get started.
Because I had the beta builds installed, I thought to clean up first. If you didn’t skip this section.
sudo rm -rf /usr/local/microsoft /Applications/PowerShell.app
sudo rm -f /usr/local/bin/pwsh /usr/local/share/man/man1/pwsh.1.gz
sudo pkgutil –forget com.microsoft.powershell
sudo rm -rf /usr/local/microsoft
sudo rm-f /usr/local/bin/pwsh
You may not need all of those but copy and paste and get it done.
If you don’t have HomeBrew installed you need to install it via these instructions. Is quick and easy. This is a package manager for macOS.
Now you need to open a Terminal window and enter the following:
brew tap caskroom/cask
Brew and PowerShell
The next command is the important one.
brew cask install powershell
So now PowerShell is installed. I open up a new Terminal prompt and type pwsh.
So I have a PowerShell prompt. On a Mac. Nice!
Now we install PowerCLI.
So while working in PowerShell we enter the following command:
Install-Module -Name VMware.PowerCLI -Scope CurrentUser
When it is finished I type the following command to see what is installed.
Get-Module VMware.* -ListAvailable
Thanks to Alex Lopez I learned another way to do that which is a bit more tidy.
Get-Module “VMware.PowerCLI” -ListAvailable | FT -Autosize
Which looks like this:
I now connect to my vCenter to see how that goes.
Connect-VIserver -server lefroy.thewhites.ca
So I see a bunch of red. Need to get rid of it. You can see the command I use to get rid of it at the bottom of the screen above.
Set-PowerCLIConfiguration -InvalidCertificateAction Ignore
Now, I try connecting again and even though I am on a Mac look what I see:
Is this nice or what!
One list thing to do – again learned from Alex Lopex is to trust the PowerShell gallery. Is optional but is also nice. The command for that is:
Set-PSRepository -Name “PSGallery” -InstallationPolicy “Trusted”
You should also remember the following command as there are updates to PowerCLI.
And that command will update any installed modules including PowerCLI.
You can upgrade PowerShell – like to 6.1 using the following commands.
brew cask upgrade powershell
- 9/16/18 – added the section on updating PowerShell core.
- 5/4/18 – fixed a typo on a command. And added the update info.
- 3/4/18 – I learned some cool things – like the nicer way for version info, and to trust the PowerShell Gallery from Alex Lopez in his article. Lots of good info!
- 3/1/18 – some small edits were needed.
- 2/28/18 – I try this again, with GA PowerShell Core and GA PowerShell 10 and it works!
- 7/23/17 – thanks to Kyle Ruddy I found out that PowerCLI and PowerShell are not yet compatible. Steve suggested I use the Docker image. Good idea!
- 7/23/17 – Done, but it doesn’t work.
I know that this was, or is, a somewhat complicated article for something so simple. But I started with beta of PowerShell core, and PowerCLI on my system and did not want to complicate anything. But it works at the end and I am quite happy with it.
=== END ===