This PowerShell Azure tutorial will discuss how to fix the error. The specified module ‘AzureRM’ was not loaded that comes while trying to import the AzureRM module using the Azure PowerShell cmdlet.
Table of Contents
The Specified Module ‘AzureRM’ Was Not Loaded
Recently, while working with the Azure PowerShell, while trying to import the AzureRM module, I got the error: The specified module ‘AzureRM’ was not loaded because no valid module file was found in any module directory. Below is the PowerShell cmdlet I executed to import the AzureRM module PowerShell.
PS C:\WINDOWS\system32> Import-Module AzureRM
Once I executed the above PowerShell cmdlet, I got the error: The specified module ‘AzureRM’ was not loaded. You can see it below
The exact error message was as below
Import-Module: The specified module ‘AzureRM’ was not loaded because no valid module
file was found in any module directory.
At line:1 char:1
- Import-Module AzureRM
~~~~~- CategoryInfo : ResourceUnavailable: (AzureRM:String) [Import-Module],
FileNotFoundException - FullyQualifiedErrorId: Modules_ModuleNotFound,Microsoft.PowerShell.Commands.Im
portModuleCommand
- CategoryInfo : ResourceUnavailable: (AzureRM:String) [Import-Module],
The Specified Module ‘AzureRM’ Was Not Loaded [Solution]
Well, to fix the above issue, we need to follow the below steps
1. Open the PowerShell ISE using the Run as Administrator mode.
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
3. Now, run the below PowerShell cmdlet to install the AzureRM module as shown below
Install-Module AzureRM -AllowClobber
Now click on the Yes to All button to confirm the installation of the AzureRM module. Once you click on the Yes to All button, the installation of the AzureRM module starts, as shown below.
4. Now, To make sure the AzureRM module is installed successfully, you can run the below PowerShell cmdlet
Get-InstalledModule
5. Now rerun the below PowerShell cmdlet to import the AzureRM module to work with the Azure PowerShell module. This time, you won’t get any error.
How to fix the error: The above steps did not load the specified module ‘AzureRM’.
You may also like following the article below
Wrapping Up
In this article, we have learned how to fix the error. The specified module ‘AzureRM’ was not loaded. I hope this will help you to fix your issue !!!
I am Rajkishore, and I have over 14 years of experience in Microsoft Azure and AWS, with good experience in Azure Functions, Storage, Virtual Machine, Logic Apps, PowerShell Commands, CLI Commands, Machine Learning, AI, Azure Cognitive Services, DevOps, etc. Not only that, I do have good real-time experience in designing and developing cloud-native data integrations on Azure or AWS, etc. I hope you will learn from these practical Azure tutorials. Read more.