I love my MacBook Pro and I like to work on macOS (although Microsoft is bringing more and more of the features I love to Windows 10).
I'm also a big fan of Automation and Infrastructure as Code, especially when working with Cloud platforms such as Azure.
For that matter, I need to have PowerShell on macOS (Yes, Azure CLI is great and I use it frequently).
Fortunately, with PowerShell Core, Microsoft has brought the goodness of PowerShell to macOS and Linux.
In this post, I'll show you how easy it is to get going with PowerShell Core on your macOS box.
You simply need to type this in a terminal:
dotnet tool install --global PowerShell
The prerequisites come down to .NET Core. In order to install it, simply download the installer from https://dotnet.microsoft.com/download. Then, it's only a matter of Continue, Continue, Install and Close. You would need at least version 2.2 of .NET Core.
You're now all set to use PowerShell Core. Simply fire up a terminal or Visual Studio Code and type the following:
This will launch a PowerShell Core session.
When you want to end that session, simply type:
Let's try to connect to Azure from my terminal on my macOS box.
For that matter, I'll need to install the
Az.Accounts module. So, here we go:
pwsh install-module Az.Accounts
Now, let's login in to Azure:
And here we are: you can now manage your Azure resources using PowerShell Core right from within your macOS box!
Don't forget to import the modules required for what you're trying to do.
Today, PowerShell is available on a wide range of platforms and this is a good thing. PowerShell has, in my humble opinion, reconciled Windows IT Pros with scripting by offering them a way more powerful tool than they ever had.
By supporting macOS and Linux as well, they can also leverage those skills to these platforms.