Working with Azure PowerShell on Mac

Since PowerShell announced as open source it has support on Linux and Mac as well and the extended support makes below possible.

  • Managing Azure using PowerShell from Linux or Mac
  • Managing Linux and Windows Containers with Docker
  • Native Linux Management with PowerShell
  • Manage AWS using PowerShell from Linux
  • Manage VMware using PowerShell from linux

Today we will look at how to install the PowerShell on Mac.

  1. First download the PowerShell package for mac from here
  2. After you download run the setup on the mac. (Make sure you allow the packages from 3rd party sources.)
  3. Once it is installed launch the terminal and type in PowerShell.
  4. Then launch the below command on the PowerShell window.Install-Module AzureRM.NetCore.Preview -Scope CurrentUser

  5. If you don’t mention the -scopeCurrent user it will throw an error message as below.  PackageManagement\Install-Package : Administrator rights are required to instal l or update. Log on to the computer with an account that has Administrator righ ts, and then try again, or install by adding “-Scope CurrentUser” to your comma nd. You can also try running the Windows PowerShell session with elevated right s (Run as Administrator).                                                       At /usr/local/microsoft/powershell/6.0.0-beta.7/Modules/PowerShellGet/1.1.3.2/P SModule.psm1:1867 char:21                                                       + …          $null = PackageManagement\Install-Package @PSBoundParameters     +                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~         + CategoryInfo          : InvalidArgument: (System.Collections.ArrayList:S     tring) [Install-Package], Exception                                              + FullyQualifiedErrorId : AdministratorRightsNeededOrSpecifyCurrentUserSco     pe,Copy-Module,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage       
  6. After the installation is complete Download the Dot Net core SDK for Mac from this link and complete the setup.
  7. Following the successful dot net setup run the below command to verify the AzureRm PowerShell is functional.
    Import-Module AzureRM.NetCore.Preview
  8. Then enter Login-AzureRMAccount to connect to your Azure portal.
  9. Open your browser and enter the url “https://aka.ms/devvicelogin” and enter the code shown above to authenticate with the portal.
  10. Once its successfully authenticated you will see on the browser as below and on the terminal you will see the portal details.
  11. From here you can launch your AzureRM PowerShell commands and manage your portal.

I hope it was informative . Let me know your feedback on this by commenting below!

4 Comments on "Working with Azure PowerShell on Mac"


  1. Hi there,

    I’ve just tried following the above steps and still get the “The term ‘Login-AzureRMAccount’ is not recognized as the name of a cmdlet, function, script file, or operable program.” error.

    Can you please help?

    Reply

    1. Can you check if all the modules are installed with the command Get-Module -List
      Post the powershell version as well?

      Reply

  2. Hi, tried to follow your tutorial with no luck

    1st issue

    Install-Module AzureRM.NetCore.Preview -Scope CurrentUser
    PackageManagement\Install-Package : No match was found for the specified search criteria and module name ‘AzureRM.NetCore.Preview’. Try Get-PSRepository to see all available registered module repositories.
    + … $null = PackageManagement\Install-Package @PSBoundParameters
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : ObjectNotFound: (Microsoft.PowerShel\u2026lets.InstallPackage:InstallPackage) [Install-Package], Exception

    Solution: i tried to install the following

    https://www.powershellgallery.com/packages/AzureRM.Netcore/0.13.2

    2nd issue

    Import-Module AzureRM.NetCore
    WARNING: AzureRM.Netcore has been deprecated. Use the ‘Az’ module instead. The ‘Az’ module is avalable from the PSGallery https://www.powershellgallery.com/packages/Az/. You can find information about getting started with ‘Az’ at https://docs.microsoft.com/en-us/powershell/azure/new-azureps-module-az. To uninstall AzureRM.Netcore you can use the provided ‘Uninstall-AzureRMNetcore’ cmdlet.

    3rd issue

    Login-AzureRMAccount
    Login-AzureRMAccount : The term ‘Login-AzureRMAccount’ is not recognized as the name of a cmdlet, function, script file, or operable program.
    Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    At line:1 char:1
    + Login-AzureRMAccount
    + ~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : ObjectNotFound: (Login-AzureRMAccount:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

    I typed the Get-Module -List

    And there are all the modules listed.

    I think the AZ modules are overriding the past modules quickly. I was just trying to follow also the tutorial:

    https://docs.microsoft.com/en-us/azure/cloud-services/cloud-services-nodejs-develop-deploy-express-app

    But when i get to the
    New-AzureServiceProject expressapp

    It crashes:

    4th issue
    The term ‘New-AzureServiceProject’ is not recognized as the name of a cmdlet, function, script file, or operable program.

    Any update or suggestion will be appreciated.

    Reply

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.