Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.
My Powershell script to connect to the Service is failing at the first hurdle:
This is how I'm trying to connect:
Import-Module MicrosoftPowerBIMgmt
Connect-PowerBIServiceAccount -Tenant xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx -ServicePrincipal -Credential (Get-Credential)
This seems to match Example 3 from MIcrosoft's guidance:
But I get the following error message:
Connect-PowerBIServiceAccount : One or more errors occurred.
At C:\Temp\Scripts\PBIScript.ps1:9 char:1
+ Connect-PowerBIServiceAccount -Tenant xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxx ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (Microsoft.Power...IServiceAccount:ConnectPowerBIServiceAccount) [Connect-PowerBIServiceAccount], AggregateException
+ FullyQualifiedErrorId : One or more errors occurred.,Microsoft.PowerBI.Commands.Profile.ConnectPowerBIServiceAccount
The account I'm trying to use to connect is covered by our MFA policy - so I am expecting to get an MFA prompt.
The script doesn't need to be automated, I'[m happy to receive a manual prompt for username, password and MFA.
Hi @Anonymous ,
Have you installed "MicrosoftPowerBIMgmt" module?
Install-Module -Name MicrosoftPowerBIMgmt
And you can also see if these posts are helpful.
https://community.powerbi.com/t5/Service/PowerShell-Login-to-Power-BI-Write-Error/m-p/1094922
Can't connect to PowerBI service account
If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Yes, I have installed the "MicrosoftPowerBIMgmt" module.
A present my script looks like this:
Import-Module MicrosoftPowerBIMgmt
Import-Module MicrosoftPowerBIMgmt.Profile
Connect-PowerBIServiceAccount
But I get the error below:
Connect-PowerBIServiceAccount : One or more errors occurred.
At C:\Temp\Scripts\PBIScript.ps1:15 char:1
+ Connect-PowerBIServiceAccount
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (Microsoft.Power...IServiceAccount:ConnectPowerBIServiceAccount) [Connect-PowerBIServiceAccount], Aggregat
eException
+ FullyQualifiedErrorId : One or more errors occurred.,Microsoft.PowerBI.Commands.Profile.ConnectPowerBIServiceAccount
Hi @Anonymous ,
This error will be thrown when the login fails. I tested and found that I could not connect using a MFA account. You need to disable the MFA for your account. Or you can use service principal and an application secret, like this
If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Disabling MFA on my account isn't an option. I have tried to connect using a service principal, but it still doesn't work:
My script:
#Import
Import-Module MicrosoftPowerBIMgmt
Import-Module MicrosoftPowerBIMgmt.Profile
#Variables
$AppId = "XXXX"
$TenantId = "XXXX"
$ClientSecret = "XXXX"
#Create secure string & credential for application id and client secret
$PbiSecurePassword = ConvertTo-SecureString $ClientSecret -Force -AsPlainText
$PbiCredential = New-Object Management.Automation.PSCredential($AppId, $PbiSecurePassword)
#Connect to the Power BI service
Connect-PowerBIServiceAccount -ServicePrincipal -TenantId $TenantId -Credential $PbiCredential
Disconnect-PowerBIServiceAccount
Error message:
Connect-PowerBIServiceAccount : One or more errors occurred.
At C:\Temp\Scripts\Script.ps1:26 char:1
+ Connect-PowerBIServiceAccount -ServicePrincipal -TenantId $TenantId - ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (Microsoft.Power...IServiceAccount:ConnectPowerBIServiceAccount) [Connect-PowerBIServiceAccount], AggregateException
+ FullyQualifiedErrorId : One or more errors occurred.,Microsoft.PowerBI.Commands.Profile.ConnectPowerBIServiceAccount
Hi @Anonymous ,
After you have successfully set up the service principal, please try the following script:
Import-Module MicrosoftPowerBIMgmt
Connect-PowerBIServiceAccount -Tenant xxxxx -ServicePrincipal -Credential (Get-Credential)
After enter, the following window will pop up, then enter your Application ID and client secret.
If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
I have tried this, and once more received the same error message as per screenshot below. My expected result is to run the Connect-PowerBIServiceAccount command without any errors (at which point I'll proceed with the rest of my script).
Hi @Anonymous ,
Have you enabled the Power BI service admin settings? For an Azure AD app to be able to access the Power BI content and APIs, a Power BI admin needs to enable service principal access in the Power BI admin portal.
Add the security group you created in Azure AD, to the specific security group section in the Developer settings.
Embed Power BI content with service principal and an application secret
If this error still persists, please use fiddler to trace details error message about that powershell request, or see if these document are helpful
Best Regards,
Winniz