Getting started with PowerShell Core and AzureRM Modules on Ubuntu and OS X

Last week, Microsoft announced PowerShell is now open sourced and available on Linux and OS X. I wrote a blog post on how to get PowerShell installed on Ubuntu 14.04, 16.04, and Mac OS X 10.11.6 if you want to check it out since this post will focus mainly on how to install the AzureRM modules and use them to manage your Azure subscription.

If you do not currently have an Azure subscription and are interested in playing around with it, you can sign up here and get a $200 credit with a 30 day free trial!

From here on down, I will assume you have PowerShell installed on your Ubuntu 14.04, 16.04, and/or OS X 10.11.6 machine.

As of the time of this writing you may have noticed that you cannot use the “Install-Module AzureRM” command as you will receive errors. This is partially due to Issue 1618, which is currently being tracked and can be followed at the provided link. Also, there are new Modules, AzureRM.NetCore.Preview, AzureRM.Profile.NetCore.Preview, and AzureRM.Resources.NetCore.Preview, created for PowerShell Core, so the workaround to install will be:

You can see a demo using these modules hereNote: The above Install-Package command is an old method. You can now use the Install-Module AzureRM.NetCore.Preview command as found in the install scripts in this updated blog post.

You can select a folder of your choosing, or use one of the following:

– /Users/[username]/.local/share/powershell/Modules (OS X 10.11.6)
– /usr/local/microsoft/powershell/6.0.0-alpha.9/Modules (OS X 10.11.6)
– /home/[username]/.local/share/powershell/Modules (Ubuntu 14.04 and 16.04)
– /opt/microsoft/powershell/6.0.0-alpha.9/Modules (Ubuntu 14.04 and 16.04)
– /usr/local/share/powershell/Modules (Ubuntu and OS X)

NOTE: If you select a folder other than one listed above, you will need to update the $ENV:PSMODULEPATH with the location you select.

To add locations to the $ENV:PSMODULEPATH use the following command: NOTE: If you simply type the following command at the command line, this will only be a temporary value.

To add a permanent one, you will want to add the command to your user profile (~/.config/powershell/profile.ps1) or default profile ($PSHOME/profile.ps1).

For Mac OS X 10.11.6 users specifically, as mentioned in issue 1874 and issue 1994 the PowerShell package for OS X is missing .NET Core pre-requisite components. This known [and reported] issue impacts some of the PowerShell cmdlets, including a lack of PowerShell Package Providers by default, and other commands such as Invoke-RestMethod as mentioned in issue 1919. With that in mind, the workaround at the time of this writing is to install .NET Core for Mac OS X. Until you do so, the Install-Package command will not work on OS X 10.11.6 El Capitan.

After you run the above command, you then will type:

The above command will then import the module into your PowerShell environment so you can begin to use AzureRM commands. After the import completes, you can test your newly installed and imported module by typing:

The above should then prompt you to head on over to https://aka.ms/devicelogin to enter the provided code.

That’s it! Feel free to comment below with any questions / feedback.

Reminder: All of my posts are provided "AS IS", imply no warranties, and confer no rights or special privileges. Use of included postings, code samples and other works are subject to the terms specified at Microsoft. For more information, click here.

Comments 10

  • Thanks for the post Jessica! Keep up the good work and keep these coming

  • Hi – I left a message over on the article about installing Powershell. Thanks for you feedback about installing .Net core. I’ve done that. However, I still get the message about NuGet when I run the Install-Package command:
    Install-Package : Unable to find package providers (NuGet).

    So I’m left unable to install the Azure module, or anything else that requires NuGet. I can’t find any basic information about getting NuGet working with Powershell on macos. Everything assumes I’m a programmer and want to learn the intricacies of setting up a Development Environment, wheras I’m a sysadmin wanting to be able to manage Azure from my Mac at home.

    I’ve installed nuget (which required mono) and can run nuget from command line (so it’s available in my path). So I guess I need to somehow tell powershell that nuget is available? Any clues that would help someone starting from scratch?

  • Great! FYI – Not sure how you installed alpha 11, but if you used the latest install script, it actually uses the Install-Module command to install AzureRm.NetCore.Preview and then you would use Import-Module to import it into PowerShell. The script calls for it, but I haven’t tested it on a completely clean install. Thank you for your patience working with me!

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.