【问题标题】:PowerShell Azure Cmdlet not RecognizedPowerShell Azure Cmdlet 无法识别
【发布时间】:2017-02-08 09:50:39
【问题描述】:

运行 PowerShell ISE (V4),我安装 AzureRM 模块如下

Import-Module AzureRM

然后我检查版本

(get-module azurerm).Version

返回

Major  Minor  Build  Revision
3      4      0      -1

然后我尝试使用登录 cmdlet

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

我做错了什么?

注意 我在代理后面工作,并使用以下命令绕过它

[System.Net.WebRequest]::DefaultWebProxy.Credentials = [System.Net.CredentialCache]::DefaultCredentials

我还将 PSGallery 存储库设置如下

Register-PSRepository -Name "PSGallery" -SourceLocation "https://www.powershellgallery.com/api/v2/" -InstallationPolicy Trusted

【问题讨论】:

  • 尝试重新安装整个模块?
  • 现在尝试Install-Module AzureRm 时,我收到错误No match was found for the specified search criteria and module name AzureRm。类似于this。将尝试再次安装PowerShellGet
  • 不。视窗 8.1。我在代理后面工作 - 不确定这是否导致我之前评论中的错误。很奇怪,因为我可以列出所有 Azure 模块,但似乎无法使用它们。
  • 你从中得到了什么:Get-Module -ListAvailable -Name Azure -Refresh
  • @juvchan:我使用该命令时没有显示任何内容。但是如果我使用Get-Module -ListAvailable -Name Azure* -Refresh,我确实会得到一个很长的列表。我需要Install-Module AzureInstall-Module AzureRM 吗?我认为前者仅适用于 ASM。

标签: powershell azure


【解决方案1】:

我已升级到 Windows Management Framework 5,现在可以运行 命令登录-AzureRMAccount

我们还可以下载 Azure PowerShell 安装文件并进行安装。 我们可以从这个页面下载PS版本3.3.0的安装文件:

https://github.com/Azure/azure-powershell/releases/tag/v3.3.0-December2016

【讨论】:

  • 只是检查提供的信息是否有用。如果您需要进一步的帮助,请告诉我。
【解决方案2】:

Login-AzureRmAccount 只是 Add-AzureRmAccount 的别名,用于访问 Azure 帐户中的 ARM 资源。

Add-AzureAccount 用于访问您的 Azure 帐户中的“经典”资源。

【讨论】:

  • 所以Add-AzureAccount 似乎工作 - 窗口打开让我添加凭据等。运行Get-AzureAccount 显示我的帐户。但是,尝试使用像 New-AzureRmResourceGroup ... 这样的命令只是错误告诉我 Run Login-AzureRmAccount - 当我尝试这样做时,我得到与以前相同的错误,即 .. is not recognized as the name of a cmdlet...
  • 你能运行Add-AzureRmAccount吗?您无法运行New-AzureRmResoucegroup,因为您仅登录访问经典资源(Add-AzureAccount)。
  • 说得有道理,但我仍然陷入困境 - 不能使用 Login-AzureRmAccount,因为它显然未被识别。
  • 您是否同时运行了Install-Module AzureRMInstall-AzureRm
  • 第一个命令从 PowerShell 库安装 AzureRM 模块。第二条命令在 AzureRM 模块中指定的模块版本范围内安装 Azure 资源管理器的所有组件模块。链接:docs.microsoft.com/en-us/powershell/resourcemanager
猜你喜欢
  • 2016-10-22
  • 2021-05-11
  • 1970-01-01
  • 2015-05-28
  • 2018-11-22
  • 2022-01-06
  • 1970-01-01
  • 2018-10-10
  • 2014-07-08
相关资源
最近更新 更多