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.

Michael Pietroforte

Michael Pietroforte is the founder and editor of 4sysops. He is a Microsoft Most Valuable Professional (MVP) with more than 30 years of experience in IT management and system administration.

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:

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:

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:

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.

Win the monthly 4sysops member prize for IT pros

Share
0

Related Posts

2 Comments
  1. Bolix 4 weeks 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

    1+

    • Author
      Michael Pietroforte 3 weeks ago

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

      Microsoft recommends to use Homebrew-Cask after installing Homebrew:

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

      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.

      0

Leave a reply

Your email address will not be published. Required fields are marked *

*

CONTACT US

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

Sending
© 4sysops 2006 - 2018

Log in with your credentials

or    

Forgot your details?

Create Account