How to Install Azure PowerShell Cmdlets and Connect to a Subscription

Table of Contents

Before you begin

Azure PowerShell requires your connecting machine to be running PowerShell version 5.0. To check, run command $PSVersionTable.PSVersion and confirm the Major build is 5.

Before Installing the Azure cmdlets for PowerShell, it is recommended to upgrade it to the PowerShell version 7.X to leverage the new features.

PS C:\> $PSVersionTable.PSVersion

Major  Minor  Build  Revision
-----  -----  -----  --------
5      1      19041  1682

Download and install Az module PowerShell

1. Right click on the Windows start icon then select Windows PowerShell Admin. In Windows 11, select Windows Terminal Admin instead of PowerShell Admin.

How to Install Azure PowerShell Cmdlets and Connect to a Subscription

2. To install the PowerShell cmdlets for Azure, you need to download and install the AZ module.

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine -Force;
Install-PackageProvider -Name NuGet -Force;
Set-PSRepository -Name "PSGallery" -InstallationPolicy Trusted;
Install-Module -Name Az -AllowClobber -Scope CurrentUser

To install it for all the users,

Install-Module -Name Az -AllowClobber -Scope AllUsers

If the AzureRM module is already installed, you first need to uninstall it because both modules AzureRM and AZ cannot reside in the same console and the AzureRm module is going to decommission soon. So anyway we need to upgrade it to the latest AZ Module.

To uninstall the AzureRM module use command.

Uninstall-Module AzureRm -Force -Verbose

Connect Azure Account using PowerShell

To connect the azure account with PowerShell, we can use the Connect-AzAccount command.

Connect-AzAccount
How to Install Azure PowerShell Cmdlets and Connect to a Subscription
PS C:\> Connect-AzAccount

Account                 SubscriptionName         TenantId                             Environment
-------                 ----------------         --------                             -----------
[email protected] Azure Pass - Sponsorship dc65dd64-6886-40f2-b247-5b10d8fb5a66 AzureCloud

Leave a Comment

Required fields are marked *