gpt4 book ai didi

powershell - 登录后 Azure 凭据不可用

转载 作者:行者123 更新时间:2023-12-03 04:19:33 25 4
gpt4 key购买 nike

我正在尝试开发 Azure PowerShell 脚本,但在登录 Azure 后在特定 PC 上获取凭据时遇到问题。

请注意:

此代码在我的家用电脑上运行没有错误,甚至在问题电脑上运行的 Windows 虚拟机上也没有错误。显示的示例在 VS Code 中运行,但我在基本 Windows PowerShell session 中遇到相同的错误。

当我运行以下代码时:

# Clear cache
Clear-AzureProfile -Force

# Log in
Connect-AzureRmAccount

# View tokens
[Microsoft.Azure.Commands.Common.Authentication.AzureSession]::Instance.TokenCache.ReadItems() | `
Select-Object -Property DisplayableId, Resource, ExpiresOn

Get-AzureRmResourceGroup -Name 'some-rg'

我收到以下错误响应:

Powershell console output

我尝试使用 Login-AzureRmAccount 和 Add-AzureAccount 进行登录,但结果相同(或缺乏)。

环境是Windows 10,我还升级到了最新的 PowerShell 和 Azure Powershell 版本。

PSVersion                      5.1.16299.431
Azure PS Version 5.2

我们很高兴收到任何不涉及重新铺设电脑的建议:-)

最佳答案

当计算机上存在多个版本的 AzureRM 模块时,这种情况很常见。

  • 您应该清理 C:\Program Files\WindowsPowerShell\ 中以 AzureRM 开头的所有目录
  • 以管理员身份运行 Powershell 并使用以下 cmdlet 安装 Azure 模块:Install-Module AzureRM -allowclobber
  • 现在重新启动 powershell,并尝试使用 Connect-AzureRmAccount 或您提到的任何 cmdlet 登录。如果存在问题,请尝试以下操作

之后,您可以尝试运行此命令来重置您的 powershell 以使用您的 azure 进行身份验证。如果 Get-AzureAccount 返回帐户详细信息,如果没有返回任何内容,则使用 Remove-AzureRmAccount

关于powershell - 登录后 Azure 凭据不可用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50396791/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com