Connect-AzAccount is Not Recognized as The Name of a Cmdlet

Table of Contents

In some cases, when you connect to Microsoft Azure PowerShell using Connect-AzAccount command. You get the following error.

Connect-AzAccount : The term ‘Connect-AzAccount’ 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.

There are two possibility causes in this case.

  1. The Azure PowerShell module isn’t installed in your machine.
  2. The Az module wasn’t successfully installed because AzureRM modules were already installed.

Note

Because Az PowerShell modules now have all the capabilities of AzureRM PowerShell modules and more, Microsoft will retire AzureRM PowerShell modules on 29 February 2024.

Case 1: Install Az PowerShell module

You can install Az module using Windows PowerShell admin.

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

Connect-AzAccount is Not Recognized as The Name of a Cmdlet

2. Copy then paste all commands into PowerShell windows to install Az PowerShell modules.

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

3. Connect to a Microsoft Azure subscription.

Connect-AzAccount

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

Case 2: Az and AzureRM modules were installed

Az modules wasn’t successfully installed because the AzureRM modules were already installed. You can added the parameter -AllowClobber to install Az modules side-by-side with the AzureRM modules.

 Install-Module -Name Az -Scope CurrentUser -Repository PSGallery -AllowClobber

Uninstalling AzureRM with command Uninstall-AzureRM may also be a great solution, because you’re not going to use AzureRM anymore. Microsoft is going to stop supporting it sometimes in February 2024.

Uninstall AzureRM then install Az modules.

Uninstall-AzureRm
Install-Module -Name Az -Scope CurrentUser -Repository PSGallery -AllowClobber

Leave a Comment

Required fields are marked *