How To Install Azure PowerShell

How To Install Azure PowerShell

This Azure tutorial will discuss the quick steps to install Azure PowerShell.

Install Azure PowerShell

If you will think now about what exactly Azure PowerShell is? Azure PowerShell contains modules that provide PowerShell cmdlets to manage the Azure resources and Windows PowerShell. To manage the Azure resources with the cmdlets, there are two ways

Azure PowerShell Module

You can Download the Azure PowerShell module and install the Azure PowerShell module on your local machine, and then you can use different PowerShell cmdlets to manage different Azure resources.

Okay, before installing the Azure PowerShell module, we should discuss the Prerequisites needed.

Prerequisites

  • You must have Windows PowerShell version 5.1 or later installed on your machine. One point to note here is if you are using Windows 10, you already have PowerShell 5.1 installed on your machine by default.
  • Install the .NET Framework 4.7.2 or later version on your local machine.
  • You must install the latest version of PowerShellGet. If you don’t have the latest version of PowerShellGet installed on your machine, then you can use the below PowerShell cmdlet to install the latest version of PowerShellGet.
PS C:\WINDOWS\system32> Install-Module -Name PowerShellGet -Force

Installing the Azure module in PowerShell

Well, we need to install the az module PowerShell now. We can install the Azure PowerShell module from the PowerShell Gallery, where all the latest Azure PowerShell modules are available.

As part of the Azure PowerShell module installation, you can install the AzureRM or Az module. One very important point to note here is that it is not suggested to install both the AzureRM and Az modules for PowerShell 5.1 on Windows simultaneously.

Az is a replacement for the AzureRM module. Az is always up to date with the latest stuff for Azure services. I feel it’s better to go with the Az module.

Follow the below steps to install the Azure PowerShell module or add the Azure PowerShell module.

1. Open the PowerShell ISE using the Run as Administrator mode.

download azure powershell msi

2. Run the below PowerShell cmdlet to ensure you have the PowerShell Get-Module installed on your local machine.

PS C:\WINDOWS\system32> Get-Module PowerShellGet -list | Select-Object Name,Version,Path
azure powershell download

3. Now install the Azure PowerShell Az Module for the current user only using the below PowerShell cmdlet. Ensure you have opened your PowerShell ISE as Run as administrator mode.

if ($PSVersionTable.PSEdition -eq 'Desktop' -and (Get-Module -Name AzureRM -ListAvailable)) {
    Write-Warning -Message ('Az module not installed. Having both the AzureRM and ' +
      'Az modules installed at the same time is not supported.')
} else {
    Install-Module -Name Az -AllowClobber -Scope CurrentUser
}

Now click on the Yes to All button to confirm the installation of the Azure Az module.

install azure powershell

4. You can install the Azure PowerShell Az Module for all users’ scope using the below PowerShell cmdlet.

if ($PSVersionTable.PSEdition -eq 'Desktop' -and (Get-Module -Name AzureRM -ListAvailable)) {
    Write-Warning -Message ('Az module not installed. Having both the AzureRM and ' +
      'Az modules installed at the same time is not supported.')
} else {
    Install-Module -Name Az -AllowClobber -Scope AllUsers
}

Click on the Yes to All button to confirm the installation of the Azure Az module for all user’s scope.

azure powershell msi

Now, once you run the above PowerShell script, it will start installing the Azure Az module, as shown below

azure powershell install

To ensure the Azure Az module is installed on your machine, run the below PowerShell cmdlet showing you the modules installed on your machine.

Get-InstalledModule
install azure powershell on windows

How to install Azure PowerShell module offline

If, by chance, you cannot connect to the PowerShell Gallery due to Environmental issues or you want to install Azure PowerShell for Windows 7, Windows 8, or Windows 10 machines, then you can also install the Azure PowerShell module offline. But first, you need to find out the Azure PowerShell download options. Follow the below instructions.

But, before the installation, you should know the Prerequisites needed.

Prerequisites

  • You must have Windows PowerShell version 5.1 installed on your machine. One point to note here is if you are using Windows 10, you already have PowerShell 5.1 installed on your machine by default.
  • Install the .NET Framework 4.7.2 or later version on your local machine.

Now, once you are ready with the Prerequisites, we can start the installation of the Azure PowerShell module using the below instruction

Download Azure PowerShell MSI

Download the Azure PowerShell MSI package from the path below and utilize the Microsoft Azure PowerShell module download option

https://github.com/Azure/azure-powershell/releases/tag/v3.7.0-March2020

You can download the 64-bit installer file. Once downloaded successfully, you can double-click on the installer file, accept the License Agreement, and click the Install button to install Azure PowerShell on Windows with MSI.

Use the Windows Azure PowerShell download for Windows 7, Windows 10, etc.

To start working with the Azure PowerShell, run the below PowerShell cmdlet, which will prompt you to log in with your Azure Credentials.

PS C:\WINDOWS\system32> Connect-AzAccount

You can install the Azure PowerShell module offline using the above instructions.

Update the Azure PowerShell Module

Once the Azure PowerShell module is installed successfully, you can run the below cmdlet anytime you want to update the Azure Power module to the latest version.

PS C:\WINDOWS\system32> Update-Module -Name Az

Once you execute the above PowerShell cmdlet, your Azure PowerShell version will get updated to the latest version.

Sign in to Azure PowerShell

You can connect or sign into Azure PowerShell using the below PowerShell cmdlet

PS C:\WINDOWS\system32> Connect-AzAccount

Once you execute the above PowerShell cmdlet, it will prompt you to provide your Azure credentials to log in.

Sign in with a managed identity

You can sign in with a managed identity. Managed identities are a feature of the Azure Active Directory. You can use the below PowerShell cmdlet to log in to the Azure PowerShell.

PS C:\WINDOWS\system32> Connect-AzAccount -Identity

Sign in with a Cloud Solution Provider (CSP)

If your account is associated with multiple tenants or you are a Cloud Solution Provider (CSP), then you need to specify the tenant ID and the PowerShell cmdlet. You can use the below PowerShell cmdlet to sign into the Azure PowerShell.

PS C:\WINDOWS\system32> Connect-AzAccount -Tenant '****-****-****-****’

Sign in with a service principal

You need to sign in with a service principal, use the -ServicePrincipal an argument along with the Connect-AzAccount PowerShell cmdlet. 

Password-based authentication

For the password-based authentication, you can use the below PowerShell script

$sp = New-AzADServicePrincipal -DisplayName ServicePrincipalName
$sp.secret | ConvertFrom-SecureString -AsPlainText

$cred = Get-Credential -UserName $sp.ApplicationId
Connect-AzAccount -ServicePrincipal -Credential $cred -Tenant $tenantId

Certificate-based authentication

You can also use the Certificate-based authentication using the below PowerShell cmdlet

PS C:\WINDOWS\system32> Connect-AzAccount -ServicePrincipal -ApplicationId $servicePrincipalId -Tenant $tenantId -CertificateThumbprint <thumbprint>

In the same way, you can also check out the quick steps to install AzureRM PowerShell.

FAQs

In which operating system, we can use Azure Powershell?

You can use Azure PowerShell in a list of operating systems like Windows 7 and the later versions, Mac OS, Linux, etc.

You may also like following the articles below

Wrapping Up

In this article, we have discussed the quick steps to install Azure PowerShell module with the help of Azure Powershell msi and command line. I hope you have enjoyed this article !!!