Powershell Error – Import-Module AzureRm

I was playing with SQL Azure on my brand new Surface pro device.  I open the Windows Powershell ISE as administrator to import AzureRm module by running the below command;

Import-Module AzureRm

It returned this error:

PS C:\windows\system32> C:\Users\User\Desktop\Azure Script.ps1
File C:\Users\User\Desktop\Azure Script.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at 
http://go.microsoft.com/fwlink/?LinkID=135170.
    + CategoryInfo          : SecurityError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : UnauthorizedAccess

This error means that the AzureRM module downloaded from internet must be signed by a trusted publisher before it can be executed. Run the below cmdlet to set the ExecutionPolicy as RemoteSigned;

PS C:\windows\system32> Set-ExecutionPolicy RemoteSigned

Now, Let’s import AzureRm module again;

Import-Module AzureRm

This time it returned different error;

PS C:\Windows\system32> Import-Module AzureRm
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.ImportModuleCommand

To fix the error, run the following cmdlet; 

PS C:\windows\system32> Install-Module -Name AzureRM -Repository PSGallery -Force

It will prompt you the below box, just hit on “Yes”

Once you click on the “Yes” button, it starts installing the software. It may take 2-5 minutes time to get completed. 

Hope, this blog helps to fix the your issue.

Thanks!

Leave a comment

Your email address will not be published. Required fields are marked *