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
This fixed the issue for me, thank you for sharing!
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) manually
2) 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)