PowerShell Core is currently available as release candidate 2 (RC2) for macOS and various other operating systems. I was pleased I could now install the Azure module (AzureRM.NetCore  aka AzureRM) on my Mac.

I played with PowerShell Core on macOS shortly after it became available. I very much liked the idea of being able to work with PowerShell on my Mac without needing to launch a virtual machine with Windows. However, I was disappointed when I noticed important modules were not working. After stumbling a couple of times along the installation path, my Mac now "loves" Azure.

Install PowerShell Core on macOS ^

My first attempt to install PowerShell Core appeared to fail. Like with the alpha version, I just downloaded the PKG package because it is the fasted method. All you have to do is double-click the file and follow the wizard. This time macOS noticed the package as trustworthy, and I didn't have to go to the security settings to approve the installation. The wizard ended with an encouraging "The installation was successful."

Installing the PowerShell Core PKG package on macOS

Installing the PowerShell Core PKG package on macOS

I then launched a Terminal, entered "powershell" and boom: -bash: powershell: command not found. This had worked with the PowerShell Core alpha. Strange, I thought. How can this happen with a release candidate? Interestingly, the package adds an app called "PowerShell" to the Application folder. However, when I clicked the corresponding icon in Launchpad, a hex file opened in my text editor (Sublime if you want to know). Weird!

So I removed the whole package with AppCleaner (one of my favorite Mac tools), downloaded the binary archives, and followed the installation instructions. For your convenience:

# Download the powershell '.tar.gz' archive
curl -L -o /tmp/powershell.tar.gz https://github.com/PowerShell/PowerShell/releases/download/v6.0.0-rc.2/powershell-6.0.0-rc.2-osx-x64.tar.gz

# Create the target folder where powershell will be placed
sudo mkdir -p /usr/local/microsoft/powershell/6.0.0-rc.2

# Expand powershell to the target folder
sudo tar zxf /tmp/powershell.tar.gz -C /usr/local/microsoft/powershell/6.0.0-rc.2

# Set execute permissions
sudo chmod +x /usr/local/microsoft/powershell/6.0.0-rc.2/pwsh

# Create the symbolic link that points to pwsh
sudo ln -s /usr/local/microsoft/powershell/6.0.0-rc.2/pwsh /usr/local/bin/pwsh

When I saw the last the command, it dawned on me what the problem with the package installation was. Someone at Microsoft felt "powershell" was too much type-type and renamed that thing to "pwsh." That's fine with me. However, why not rename PowerShell to "posh?" Sounds almost as if PowerShell were the high-class edition of "bash." 😉

Install the AzureRM module on PowerShell Core ^

I was tempted to try the package installation again, but then I was too curious to find out how powerful PowerShell (or pwsh) is on a Mac. (Let me know if this worked for you.) Of course, the first thing I tried to install was the Azure module:

Install-Module AzureRM

Don't try this! Even though the installation went through without error messages, it didn't work. After I typed Login-AzureRmaccount, I received this:

Login-AzureRmaccount: The term 'Add-AzureRmAccount' is not recognized as the name of a cmdlet, function, script file, or operable program.

This is not what I expected. I wasn't ready to give up yet though. I couldn't believe Microsoft offered a release candidate for PowerShell Core without support for Azure. So I removed the module, googled a little, and found some blog posts that claimed to explain how to install AzureRM on PowerShell Core. I failed again in a similar way. Many PowerShell Core articles out there no longer work. Finally, I found this one. This worked. Not exactly as described, but it worked.

The main thing on PowerShell Core is that you don't install the AzureRM module but AzureRM.NetCore:

Install-Module AzureRM.NetCore

Lesson learned. PowerShell Core is not really PowerShell, and many modules will have to be adapted. Nevertheless, if you try the above command at a freshly installed PowerShell Core prompt, you will probably receive this error message (after Install-Module downloads the module):

PackageManagement\Install-Package : Administrator rights are required to install or update.

Fair enough. I should have known this. But I am on a Mac, so no right-click, Run as Administrator thingy. Instinctively, I entered sudo Install-Module AzureRM.NetCore. To my surprise I received a password prompt. Huh? PowerShell learned how to sudo? Not so fast:

sudo: install-module: command not found

What a pity! I would have liked this. But this works: Exit the PowerShell console by typing exit and then enter sudo pwsh. Now you have a PowerShell console with administrator rights, and you can install modules.

After entering Install-Module AzureRM.NetCore again, PowerShell Core warned me I'm installing modules from an untrusted repository. Microsoft's not trustworthy? Who says that?

Microsoft's documentation claims you then have to import the module with Import-Module AzureRM.Netcore. However, for me it worked without that, probably because I restarted the PowerShell console.

After I entered Login-AzureRmAccount, it greeted me with a longwinded warning that explained why Microsoft wants to collect data about my usage of cmdlets. I don't know about you, but I don't feel like sharing all of my failed and embarrassing PowerShell attempts. And hey, didn't I just install software from an untrustworthy source I now should trust with my most personal data?

Install Azure module (AzureRM.NetCore ) on PowerShell Core

Install Azure module (AzureRM.NetCore ) on PowerShell Core

So I answered the suggestive request "Select Y to enable data collection Y/N" with a distinct "N." I almost had to laugh when I received another WARNING: You choose not to participate in Microsoft Azure PowerShell data collection. Okay, I've been warned and I understand the risks of not sending all of my data to Microsoft.

Shortly afterward, another WARNING appeared informing me I had to open a web browser to the URL https://aka.ms./devicelogin and enter an authentication code. This warning I took seriously, and seconds after I followed the instructions, my Mac and Azure were finally friends. I find it odd (to say the least) I need to open a web browser to sign in from a console.

The next thing I need to do is change the color of these ugly yellow warning messages. I somehow think I will see these WARNINGS more often on my Mac in the months to come.

  1. Bolix 5 years ago

    Install compiler tools, homebrew and then powershell:

    xcode-select –install
    ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”
    brew cask install powershell

    • Author
      Michael Pietroforte 5 years ago

      Yeah, homebrew is another option. Never used it. Is it worth installing?

      Microsoft recommends to use Homebrew-Cask after installing Homebrew:

      brew tap caskroom/cask
      brew cask install powershell

      The nice thing of installing PowerShell with Homebrew-Cask is that you can then update when a new version is available:

      brew update
      brew cask reinstall powershell

      I am just not sure if you want to install a package manager, just to install PowerShell. I hope Microsoft will make PowerShell available through the App Store.

  2. Preamble 5 years ago

    Awesome!! I’ve been trying to get this to work for months!

    I had to run these commands before trying to login, then everything worked:

    Import-Module AzureRM.Netcore

    Import-Module AzureRM.Profile.Netcore

    Thank You!!! No more VirtualBox!

Leave a reply

Your email address will not be published.


© 4sysops 2006 - 2022


Please ask IT administration questions in the forums. Any other messages are welcome.


Log in with your credentials


Forgot your details?

Create Account