【问题标题】:Get-AzureADApplication throwing error while fetching Azure AD application details获取 Azure AD 应用程序详细信息时 Get-AzureADApplication 引发错误
【发布时间】:2018-08-20 23:14:46
【问题描述】:

我正在尝试使用 Get-AzureADApplication 命令获取 Azure AD 应用程序详细信息。 但是这个命令抛出了错误。

"Get-AzureADApplication :您必须先调用 Connect-AzureAD cmdlet,然后才能调用任何其他 cmdlet。 在 D:\Scripts\Test.ps1:18 char:10 + $myApp = Get-AzureADApplication -Filter "DisplayName eq '$($AppName)' ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Get-AzureADApplication], AadNeedAuthenticationException + FullyQualifiedErrorId : Microsoft.Open.Azure.AD.CommonLibrary.AadNeedAuthenticationException,Microsoft.Open.AzureAD16.PowerShell.GetApplication"

最糟糕的是,这个命令几天前和今天在执行脚本时都在工作。我收到这个错误。 我还提到了下面提到的链接,但找不到解决方案。

Error while fetching AAD app information using Get-AzureADApplication

【问题讨论】:

    标签: powershell azure-active-directory


    【解决方案1】:

    首先,您是否安装了 Azure Active Directory PowerShell 模块?如果是,则使用Connect-AzureAD 登录到 Azure,将弹出一个窗口供您使用 Microsoft 凭据登录。如果您喜欢跳过登录弹出窗口,请关注documentation

    仅将这个小技巧用于本地开发。不适用于客户端/远程机器。 要在每次使用 powershell 时跳过登录提示,

    • 以管理员身份打开 Windows PowerShell
    • 键入记事本 $profile。
    • 它会打开一个记事本文件,在这里你可以 粘贴以下代码,以便 PowerShell 随时自动登录 它已打开。
    • 保存文件,下次重新启动 PowerShell 时,您可以看到每当调用 PowerShell 会话时它都会自动登录到 Azure 门户。

      $username = "enter your username"
      $password = "enter password"
      $securepasswd = ConvertTo-SecureString $password -AsPlainText -Force
      $cred = New-Object System.Management.Automation.PSCredential ($username, $ securepasswd)
      Connect-AzureRmAccount -Credential $cred
      

    【讨论】:

    • Azure AD powershell 已安装,但我仍然面临这个问题。我正在使用 Connect-AzureRmAccount 登录,因为我不想弹出窗口。
    • 好的,所以你不想弹出?如果您不介意将密码编码到本地计算机中?
    • $ssAADKey = ConvertTo-SecureString $AADKey -AsPlainText -Force $psCredential = New-Object System.Management.Automation.PSCredential($AADAppID, $ssAADKey) Connect-AzureRmAccount -ServicePrincipal -Credential $psCredential -租户 ID $TenantId
    • 我认为我们正在转移真正的问题,我的问题是 Get-AzureADapplication is throwing error not Login
    • 也想补充一下,我的同事系统中也可以使用相同的代码,但我的系统中没有
    【解决方案2】:

    Get-AzureAdApplication 来自与 Connect-AzureRmAccount (AzureRM) 不同的模块 (AzureAD),因此我认为您需要使用相关的 AzureRM 命令,例如获取 AzureRmADApplication。

    由于我不知道您要实现什么,也许值得检查 AzureRM 命令。

    Get-Command -Module AzureRM

    【讨论】:

      猜你喜欢
      • 2019-11-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多