Forum Discussion
PowerShell Login with Connect-PowerBIServiceAccount +ServicePrincipal error
- 6 years ago
Forget about my message. I found the solution. Everything is now running fully as expected😊🌟🌟🌟
Forget about my message. I found the solution. Everything is now running fully as expected😊🌟🌟🌟
- yandra5 years agoRegular Visitor
Hi,
I am doing some automation using PowerShell script with Power BI REST API. And, I came across your post.
Could you share the solution to overcome 403 forbidden status for subsequent call?
Thanks!
- Anonymous4 years agoNot applicable
What was the solution MawashiKid2 ?
- rockymtnrajah4 years agoFrequent Visitor
The solution is to use an SPN (Register an app to embed Power BI content in a Power BI embedded analytics application - Power BI | Microsoft Docs). Once you have an SPN your code will change to:
#replace bold items with your values
$applicationId = "<guid>";
$securePassword = "<password>" | ConvertTo-SecureString -AsPlainText -Force
$credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $applicationId, $securePassword
Connect-PowerBIServiceAccount -ServicePrincipal -Credential $credential -TenantId "<tenantid-guid>"