登录-AzureRmAccount 和 Select-AzureRmSubscription

Login-AzureRmAccount and Select-AzureRmSubscription

我已经在 Windows 服务器 2012 R2 上安装了 AzureRm 和 Azure 模块。我可以 运行 来自此模块的其他 cmdlet(eg.AddAzureRmAccount、Get-AzureRmSubscription)但是 Login-AzureRmAccount 和 Select-AzureRmSubscription 抛出无法识别的错误:

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

我已经尝试过卸载-重新安装并重新启动虚拟机。

我在这里做错了什么?如果有人以前解决过这个问题,请提出解决方案。

好像他们的 powergallery 设置坏了,我用 webPI 安装了它,它工作正常。

webPI 下载说明:

https://regularitguy.com/2014/03/13/installing-the-windows-azure-powershell-cmdlets/

  • 使用最新版本的 Web 平台安装 Azure Powershell 安装程序。
  • 您可能需要重新启动您的机器 - 以便最新的 powershell升级生效
  • 打开 Powershell 或 Powershell_ise 并尝试执行以下命令:

Login-AzureRmAccount

  • 弹出窗口 window 出现提示您的 Microsoft Azure 帐户凭据。

Install-Module AzureRM -Scope CurrentUser

  • 同时使用以下命令检查您安装的 azure 模块。

Get-Module -List

  • 您已完成设置。使用您的 Azure powershell 脚本。

注意: 请使用 azure RM 登录以通过服务主体连接:

$applicationId = "$securePassword = "ServicePrincipal Passowrd" | ConvertTo-SecureString -AsPlainText -Force
$credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $applicationId, $securePassword
Connect-AzureRmAccount -ServicePrincipal -Credential $credential -TenantId "ServicePrincipal Tenant ID"