Forum Discussion
MawashiKid2
6 years agoAdvocate I
PowerShell Login with Connect-PowerBIServiceAccount +ServicePrincipal error
Hi, I am currently testing PowerShell scripts in combination with Power BI REST API which I intend to use in automation scenarios. At this stage, all tests were successfully completed manually thro...
- 6 years ago
Forget about my message. I found the solution. Everything is now running fully as expected😊🌟🌟🌟
Anonymous
4 years agoNot applicable
What was the solution MawashiKid2 ?
rockymtnrajah
4 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>"