Connect-PowerBiServiceAccount 无法与服务主体连接
Connect-PowerBiServiceAccount unable to connect with Service Principal
我正在使用 Powershell 的 MicrosoftPowerBIMgmt 模块连接到 Power BI,以便我可以上传报告,但无法成功连接。我已经尝试在 windows 10 enterprise machine 和 mac 运行 powershell core 上使用此代码。
我正在尝试使用以下代码使用服务主体进行连接:
$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"
输出---
我正在使用 Powershell 的 MicrosoftPowerBIMgmt 模块连接到 Power BI,以便我可以上传报告,但无法成功连接。我已经尝试在 windows 10 enterprise machine 和 mac 运行 powershell core 上使用此代码。
我正在尝试使用以下代码使用服务主体进行连接:
$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"
输出---