The term Get-AzureAccount is not recognized error: How to fix it

In this tutorial, we will learn How to solve the error “The term Get-AzureAccount is not recognized, The specified module ‘Azure’ was not loaded because no valid module file was found” while using PowerShell.

You might have come across the above error while trying to get your Azure subscription details with the help of a PowerShell command Get-AzureAccount.

The term Get-AzureAccount is not recognized

Why we get this error ?

Let’s execute the PowerShell command.

Get-AzureAccount: This command will get and show the available Azure accounts in PowerShell

SYNTAX

PS C:\> Get-AzureAccount
The term Get-AzureAccount is not recognized error

Below is the error message ( The term Get-AzureAccount is not recognized ) which we get after executing Get-AzureAccount

Get-AzureAccount : The term ‘Get-AzureAccount’ 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

  • Get-AzureAccount
  • ~~~~
    • CategoryInfo : ObjectNotFound: (Get-AzureAccount:String) [], CommandNotFoundException
    • FullyQualifiedErrorId : CommandNotFoundException
How To Fix msvcp140.dll Missing Err...
How To Fix msvcp140.dll Missing Error on Windows 10

The reason we are getting this error is that the Azure Power Shell module is not installed in the System.

How to Fix the error ?

#To fix this error we need to install the Azure PowerShell module.

Follow the below method on  PowerShell 7.0.6 LTS and PowerShell 7.1.3 or higher.

Step 1: Open PowerShell with administrator access.

Go to Windows PowerShell, right-click and Run as administrator

Use the below cmd to import the Azure module using PowerShell

PS C:\WINDOWS\system32> Install-Module -Name Az -Scope CurrentUser -Repository PSGallery -Force

Type Y to confirm

This will install the Azure PowerShell module and fix the error.

To install the module in PowerShell 5.1 on Windows use the below Powershell command :

Install-Module -Name PowerShellGet -Force

Above command will install the PowerShell Get module .

How to add Azure account with Add-AzureAccount

Using Add-AzureAccount you can add the Azure account to PowerShell using the legacy Azure resources that use Service Management APIs (classic mode) .

It will download and save the your Azure account information in your userprofile .

You can use the below Syntax :

Add-AzureAccount
   [-Environment <String>]
   [-Credential <PSCredential>]
   [-Tenant <String>]
   [-Profile <AzureSMProfile>]
   [<CommonParameters>]

List Azure account with Get-AzureAccount

Get-AzureAccount will list the available Azure accounts in PowerShell.

To Get all the available accounts use the below Syntax.

Get-AzureAccount
   [-Name <String>]
   [-Profile <AzureSMProfile>]
   [<CommonParameters>]

Example :

This command returns a list of all accounts linked to the specified user.

PS C:\> Get-AzureAccount

Name                         ActiveDirectories
----                         -----------------
admin@addnewskills.com     {{ ActiveDirectoryTenantId = abcde5cd-bwc3-441a-bd86-e6a...
contosotest1@outlook.com     {{ ActiveDirectoryTenantId = aacabcde-376c-4563-bf80-794...

How to add Azure account with Add-AzureRmAcccount

This will add an Azure account to use with interactive login in PowerShell.

This command can only be used with Azure Resource Manager cmdlets.

Syntax

Add-AzureRmAccount
   [-Environment <String>]
   [[-Credential] <PSCredential>]
   [-TenantId <String>]
   -SubscriptionName <String>
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]

Example :

PS C:\>Add-AzureRmAccount
Account: adming@addnewskills.com
Environment: AzureCloud
Subscription: xxxx-xxxx-xxxx-xxxx
Tenant: xxxx-xxxx-xxxx-xxxx
  • An Azure Resource Manager account is created using the above command.
  • You must enter Microsoft account or organizational ID credentials at the prompt to run Azure Resource Manager cmdlets with this account.

Wrapping up

We hope this tutorial on How to The term Get-AzureAccount is not recognized error was helpful.As Microsoft is constantly changing the documentation with rapidly changing technology.It is always recommended to check the updated Microsoft Docs.

Other Useful articles :

How to fix Because of Protocol Error Code 0x112d 

AZ-120 Exam Study Guide