powershell - Connect-PowerBiServiceAccount 无法与服务主体连接
问题描述
我正在使用 Powershell 的 MicrosoftPowerBIMgmt 模块连接到 Power BI,以便我可以上传报告,但无法成功连接。我曾尝试在 Windows 10 企业机器和运行 powershell 内核的 mac 上使用此代码。
我正在尝试使用以下代码使用服务主体进行连接:
$applicationId = "XXX"
$securePassword = "XXX" | ConvertTo-SecureString -AsPlainText -Force
$credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $applicationId, $securePassword
Connect-PowerBIServiceAccount -ServicePrincipal -Credential $credential -TenantId "XXX"
我收到以下错误
WARNING: (False) MSAL 4.25.0.0 MSAL.NetCore Darwin 20.5.0 Darwin Kernel Version 20.5.0: Sat May 8 05:10:33 PDT 2021; root:xnu-7195.121.3~9/RELEASE_X86_64 [11/15/2021 14:34:38 - 677c9e5e-9df6-4912-bdd3-994f59c64646] Fetching a new AT failed. Is AAD down? False. Is there an AT in the cache that is usable? False
WARNING: (False) MSAL 4.25.0.0 MSAL.NetCore Darwin 20.5.0 Darwin Kernel Version 20.5.0: Sat May 8 05:10:33 PDT 2021; root:xnu-7195.121.3~9/RELEASE_X86_64 [11/15/2021 14:34:38 - 677c9e5e-9df6-4912-bdd3-994f59c64646] Either the exception does not indicate a problem with AAD or the token cache does not have an AT that is usable.
WARNING: (False) MSAL 4.25.0.0 MSAL.NetCore Darwin 20.5.0 Darwin Kernel Version 20.5.0: Sat May 8 05:10:33 PDT 2021; root:xnu-7195.121.3~9/RELEASE_X86_64 [11/15/2021 14:34:38 - 677c9e5e-9df6-4912-bdd3-994f59c64646] Exception type: Microsoft.Identity.Client.MsalServiceException
, ErrorCode: invalid_client
HTTP StatusCode 401
解决方案
我测试过,它对我来说工作正常。如果我使用 SecurePassword 的密码而不是客户端密码,我会遇到同样的错误。
您可以使用新的客户端密码创建您的应用程序密钥。
$applicationId = "your application Client ID"
$securePassword = " application Cleint secret value " | ConvertTo-SecureString -AsPlainText -Force
$credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $applicationId, $securePassword
Connect-PowerBIServiceAccount -ServicePrincipal -Credential $credential -TenantId "Your tenant ID"
推荐阅读
- aws-cdk - 使用 AWS CDK 获取 VPC 的 CIDR 的最佳方法是什么?
- django - 如何在 Django-Vieflow 中为用户分配任务
- javascript - 当我有一个 Javascript 函数包含一个外部 Javascript 文件时,如何使函数块直到外部文件完全加载?
- javascript - mongodb从方面返回对象
- python - % 数组中的元组?python(不将元组附加到数组中)
- angular - 使用 Angular 绑定 ngModelGroup 的名称
- haskell - Haskell 递归循环计数器
- javascript - 如何通过每种颜色在 Google 地图上获取形状绘制的 ID/数字顺序
- android - 如何在android中设置Imageview右端对齐到textview
- java - 无法将 gradle 项目导入 Eclipse Photon