I am getting the error below while trying to login to azure using the power shell
PS C:\WINDOWS\system32> Login-AzureRmAccount
Login-AzureRmAccount : The term 'Login-AzureRmAccount' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is
correct and try again.
At line:1 char:1
+ Login-AzureRmAccount
+ ~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Login-AzureRmAccount:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
PS C:\WINDOWS\system32>
In order to fix this I have done the installation of required module and it has started working fine.
PS C:\WINDOWS\system32> Install-Module -Name AzureRM -AllowClobber
PS C:\WINDOWS\system32>
But then I started getting another error:
PS C:\WINDOWS\system32> Login-AzureRmAccount
Login-AzureRmAccount : The 'Login-AzureRmAccount' command was found in the module 'AzureRM.profile', but the module could not be loaded. For more information, run 'Import-Module AzureRM.profile'.
At line:1 char:1
+ Login-AzureRmAccount
+ ~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Login-AzureRmAccount:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CouldNotAutoloadMatchingModule
PS C:\WINDOWS\system32>
Then another one :-(
PS C:\WINDOWS\system32> Import-Module AzureRM.profile
Import-Module : File C:\Program Files\WindowsPowerShell\Modules\AzureRM.profile\5.8.2\AzureRM.Profile.psm1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies
at https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1
+ Import-Module AzureRM.profile
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : SecurityError: (:) [Import-Module], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess,Microsoft.PowerShell.Commands.ImportModuleCommand
PS C:\WINDOWS\system32>
The I had to install the module
PS C:\WINDOWS\system32> Install-Module -Name AzureRM.profile
PS C:\WINDOWS\system32>
Finally noticed that the execution policy is set to Restricted and it should be Unrestricted.
PS C:\WINDOWS\system32> Get-ExecutionPolicy
Restricted
PS C:\WINDOWS\system32> set-executionpolicy Unrestricted
PS C:\WINDOWS\system32>
PS C:\WINDOWS\system32> Get-ExecutionPolicy
Unrestricted
PS C:\WINDOWS\system32>
and there we go the azure login script is working now.
PS C:\WINDOWS\system32> Login-AzureRmAccount
Account SubscriptionName TenantId Environment
------- ---------------- -------- -----------
XFtxxxxxxxx@xxxxxxxxxx.com Azuxxxx 00000000-0000-0000-0000-000000000000 AzureCloud
PS C:\WINDOWS\system32>
PS C:\WINDOWS\system32> Login-AzureRmAccount
Login-AzureRmAccount : The term 'Login-AzureRmAccount' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is
correct and try again.
At line:1 char:1
+ Login-AzureRmAccount
+ ~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Login-AzureRmAccount:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
PS C:\WINDOWS\system32>
In order to fix this I have done the installation of required module and it has started working fine.
PS C:\WINDOWS\system32> Install-Module -Name AzureRM -AllowClobber
PS C:\WINDOWS\system32>
But then I started getting another error:
PS C:\WINDOWS\system32> Login-AzureRmAccount
Login-AzureRmAccount : The 'Login-AzureRmAccount' command was found in the module 'AzureRM.profile', but the module could not be loaded. For more information, run 'Import-Module AzureRM.profile'.
At line:1 char:1
+ Login-AzureRmAccount
+ ~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Login-AzureRmAccount:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CouldNotAutoloadMatchingModule
PS C:\WINDOWS\system32>
Then another one :-(
PS C:\WINDOWS\system32> Import-Module AzureRM.profile
Import-Module : File C:\Program Files\WindowsPowerShell\Modules\AzureRM.profile\5.8.2\AzureRM.Profile.psm1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies
at https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1
+ Import-Module AzureRM.profile
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : SecurityError: (:) [Import-Module], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess,Microsoft.PowerShell.Commands.ImportModuleCommand
PS C:\WINDOWS\system32>
The I had to install the module
PS C:\WINDOWS\system32> Install-Module -Name AzureRM.profile
PS C:\WINDOWS\system32>
Finally noticed that the execution policy is set to Restricted and it should be Unrestricted.
PS C:\WINDOWS\system32> Get-ExecutionPolicy
Restricted
PS C:\WINDOWS\system32> set-executionpolicy Unrestricted
PS C:\WINDOWS\system32>
PS C:\WINDOWS\system32> Get-ExecutionPolicy
Unrestricted
PS C:\WINDOWS\system32>
and there we go the azure login script is working now.
PS C:\WINDOWS\system32> Login-AzureRmAccount
Account SubscriptionName TenantId Environment
------- ---------------- -------- -----------
XFtxxxxxxxx@xxxxxxxxxx.com Azuxxxx 00000000-0000-0000-0000-000000000000 AzureCloud
PS C:\WINDOWS\system32>
1 comment:
thank you for your post. :)
Post a Comment