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
Thank you for sharing the step to connect to azure account using power shell.