Home > Microsoft Azure, Powershell > Powershell error – Import-Module : File AzureRM.psm1 cannot be loaded because running scripts is disabled on this system

Powershell error – Import-Module : File AzureRM.psm1 cannot be loaded because running scripts is disabled on this system


 
After installing the AzureRM module, I tried to import it, but it gave me an error:

Import-Module : File C:\Program Files\WindowsPowerShell\Modules\AzureRM\4.0.2\AzureRM.psm1 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.
At line:1 char:1
+ Import-Module AzureRM
+ ~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : SecurityError: (:) [Import-Module], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess,Microsoft.PowerShell.Commands.ImportModuleComman
d

This error means that the AzureRM module downloaded from internet must be signed by a trusted publisher before they can be run.
 

–> Now to fix it you need to change the execution policy by this simple command:

PS c:\> Set-ExecutionPolicy RemoteSigned

If you are on PowerShell Window then it will throw a popup to confirm to change the Execution policy, you can choose “Yes”:

Now try running again the import command, it will run:

PS c:\> Import-Module AzureRM


Advertisement
  1. Deepak Singhal
    May 12, 2020 at 10:24 am

    Thank you for sharing the step to connect to azure account using power shell.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: