The ‘Get-AzResourceGroup’ command was found in the module ‘Az.Resources’

In this article, we will discuss how to fix the error “The ‘Get-AzResourceGroup’ command was found in the module ‘Az.Resources’, but the module could not be loaded” that I got while trying to execute the Get-AzResourceGroup Azure PowerShell cmdlet to retrieve the list of Azure Resource Groups.

The ‘Get-AzResourceGroup’ command was found in the module ‘Az.Resources’, but the module could not be loaded

Recently, I was required to retrieve all the Resource Groups using Azure PowerShell. So I have executed the Get-AzResourceGroup Azure PowerShell cmdlet.

The moment I executed the Get-AzResourceGroup Azure PowerShell cmdlet, I got the following error.

The ‘Get-AzResourceGroup’ command was found in the module ‘Az.Resources’, but the module could not be loaded

The complete error message was as below

Get-AzResourceGroup : The 'Get-AzResourceGroup' command was found in the module 
'Az.Resources', but the module could not be loaded. For more information, run 
'Import-Module Az.Resources'.
At line:1 char:1
+ Get-AzResourceGroup -Location westus2 |
+ ~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Get-AzResourceGroup:String) [], Comman 
   dNotFoundException
    + FullyQualifiedErrorId : CouldNotAutoloadMatchingModule
 

You can see the same error here

the term 'get-azresourcegroup' is not recognized as the name of a cmdlet

Now, let’s find out the way to fix this issue.

Solution

Now, to fix this issue, we need to import the Az.Resources module, we can run the Get-AzResourceGroup Azure PowerShell cmdlet.

Note: If you are getting any errors while importing the Az.Resources, try opening a new PowerShell session and run the import cmdlet.

Run the following Azure PowerShell command to import Az.Resources module.

Import-Module -Name Az.Resources

Then, you can run the Get-AzResourceGroup Azure PowerShell cmdlet.

Get-AzResourceGroup

Or, you can execute the Azure PowerShell cmdlet as below.

Import-Module -Name Az.Resources
Get-AzResourceGroup

Once I executed the Azure PowerShell cmdlet, I got the expected output below.

get-azresourcegroup is not recognized

Voila! How easy to fix the issue The ‘Get-AzResourceGroup’ command was found in the module ‘Az.Resources’. Now, it’s your turn to fix the same issue following the above instructions.

You may also like the following articles below.

Azure Virtual Machine

DOWNLOAD FREE AZURE VIRTUAL MACHINE PDF

Download our free 25+ page Azure Virtual Machine guide and master cloud deployment today!