Forum Discussion
(PowerShell) Connect-PowerBIServiceAccount not working
- 4 years ago
Problem found and solved!
It turned out that an update to the PowerShell extension for VS Code set this value "powershell.useX86Host": true. In other words, it started running 32 bit as default. Manually changing it back to x64 like shown in the screenshots belov solved the problem:
Cheers, Mike
Thank you for the feedback. I have tried this solution, but unfortunately it did not solve the problem. May I ask what dev tools you are using? I am using VS code with powershell 5.1 for development.
I was running the commands from the standard Windows PowerShell terminal (5.1) as administrator. I also have VS Code, but I don't use very complex scripts so there's nothing much to develop at the moment.
- h4tt3n4 years agoHelper V
This is interesting: The script runs fine in the PowerShell ISE editor, but it won't run in VS code. IF you are having problems, try updating the MicrosoftPowerBIMgmt module with the command:
Install-Module MicrosoftPowerBIMgmt -force -AllowClobber
and then run the script in either PS command line tool or ISE. This has worked for me.
However, since VS code is a superior toll over cmd or ISE, and sinc it is a Microsoft product, I am holding my support ticket open.- carloscantu4 years agoAdvocate III
This fixed the issue for me, thank you for sharing!
- agneum4 years agoHelper II
I was using Service Principal method to sign in and had the same error. I was noticed it was working fine in x86 version of PowerShell ISE however.
The problem
Connect-PowerBIServiceAccount -ServicePrincipal -CertificateThumbprint xxxx -ApplicationId xxxx
..Kept throwing errors such as :Login-PowerBIServiceAccount : One or more errors occurred.
At line:1 char:1
+ Login-PowerBIServiceAccount
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (Microsoft.Power...IServiceAccount:ConnectPowerBIServiceAccount) [Connect-PowerBIServiceAccount], AggregateException
+ FullyQualifiedErrorId : One or more errors occurred.,Microsoft.PowerBI.Commands.Profile.ConnectPowerBIServiceAccount--
My solution was this:
1) Close all open powershell sessions. Go to C:\Program Files\WindowsPowerShell\Modules and delete all MicrosoftPowerBIMgmt modules (folders) manually2) Open PowerShell ISE as admin , and run
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 Unregister-PSRepository -Name PSGallery Register-PSRepository -Default
3) Make sure this command works and finds shows version of 1.2.1077 (or above)
Find-Module MicrosoftPowerBIMgmt
3) Install the module again
Install-Module MicrosoftPowerBIMgmt -force -AllowClobber
The service account (app registration) needed access to the Power BI API, and I also had to enable "Allow service principals to use Power BI APIs" under tenant settings. (I used security group at first, but removed it, not sure if it's related to the issue)