【问题标题】:Get-AzureAccount is not working in Az modulesGet-AzureAccount 在 Az 模块中不起作用
【发布时间】:2020-07-07 10:13:42
【问题描述】:

Get-AzureAccount 在 Az 模块中不起作用。它给出以下错误:

Get-AzureAccount : The 'Get-AzureAccount' command was found in the module 'Azure', but the module could not be loaded. For more information, run 'Import-Module Azure'.
+     Get-AzureAccount | ForEach-Object { Remove-AzureAccount $_.ID -Fo ...
+     ~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Get-AzureAccount:String) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : CouldNotAutoloadMatchingModule

此命令在 AzureRM 模块中工作,因为 AzureRm 正在贬低,我们需要将所有命令更改为 Az 模块。

请帮助! 提前致谢

【问题讨论】:

  • 您好,如果您的回答对您有帮助,您可以采纳吗?谢谢。

标签: powershell azure-powershell azure-rm az


【解决方案1】:

使用 Az 登录 Azure 的命令是:

Connect-AzAccount

安装 PowerShell Core 7 并安装 Az 这样你就可以同时运行 AzureRm 和 Az

Uninstall-AzureRm

Find-Module -Name Az | Install-Module -AllowClobber

【讨论】:

    【解决方案2】:

    如果您安装了Az module,则应使用Get-AzContext 而不是Get-AzureAccount

    我看到你也使用了Remove-AzureAccount,但在Az module,你应该使用Remove-AzContext

    示例代码如下所示:

    Get-AzContext | ForEach-Object { Remove-AzContext -Name $_.name -Force} 
    

    【讨论】:

      猜你喜欢
      • 2019-08-20
      • 1970-01-01
      • 2022-06-10
      • 2011-09-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多