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.
I want to use Power BI PowerShell module. This is what I have done:
1. I got Power BI Moduel installed in PowerShell
2. I got an app registered with the following permissions:
(This message is shown on the top of the permissions screen)
3. I added the Service Principal to a security group and granted him access in Power BI Admin Portal:
E.g.
4. I authenticate in Power Shell using this code:
$client_id = <>
$tenant_id = <>
$secret = <>
$SecurePassword = ConvertTo-SecureString $secret -Force -AsPlainText
$servicePrincipal = New-Object -TypeName PSCredential -ArgumentList $client_id, $SecurePassword
Connect-PowerBIServiceAccount -ServicePrincipal -Credential $servicePrincipal -Tenant $tenant_id
5. I try to call APIs from PowerShell:
Invoke-PowerBIRestMethod -Url 'https://api.powerbi.com/v1.0/myorg/admin/groups/<Group ID>/users' -Method Get
I get the following error message:
Invoke-PowerBIRestMethod : One or more errors occurred.
At line:1 char:1
+ Invoke-PowerBIRestMethod -Url 'https://api.powerbi.com/v1.0/myorg/adm ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (Microsoft.Power...werBIRestMethod:InvokePowerBIRestMethod) [Invoke-PowerBIRestMethod], AggregateException
+ FullyQualifiedErrorId : One or more errors occurred.,Microsoft.PowerBI.Commands.Profile.InvokePowerBIRestMethod
Invoke-PowerBIRestMethod : Encountered errors when invoking the command: {
"code": "PowerBINotAuthorizedException",
"pbi.error": {
"code": "PowerBINotAuthorizedException",
"parameters": {},
"details": [],
"exceptionCulprit": 1
}
}
At line:1 char:1
+ Invoke-PowerBIRestMethod -Url 'https://api.powerbi.com/v1.0/myorg/adm ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (Microsoft.Power...werBIRestMethod:InvokePowerBIRestMethod) [Invoke-PowerBIRestMethod], Exception
+ FullyQualifiedErrorId : Encountered errors when invoking the command: {
"code": "PowerBINotAuthorizedException",
"pbi.error": {
"code": "PowerBINotAuthorizedException",
"parameters": {},
"details": [],
"exceptionCulprit": 1
}
},Microsoft.PowerBI.Commands.Profile.InvokePowerBIRestMethod
Can you please assist me to know what did I miss?
Thanks
Solved! Go to Solution.
Hi @BoNDoK00 , it looks like you are trying to connect using a Service Principal to use the Power BI Admin Rest API. There is an important part in the documentation: Enable service principal authentication for read-only admin APIs - Power BI | Microsoft Learn
If you delete all the Power BI API setting in the Azure Portal the "PowerBINotAuthorizedException" should be avoided.
I have similar issue and got the same error but only for some workspaces. For most of the other workspaces, the powershell script works fine.
Hi @BoNDoK00 , it looks like you are trying to connect using a Service Principal to use the Power BI Admin Rest API. There is an important part in the documentation: Enable service principal authentication for read-only admin APIs - Power BI | Microsoft Learn
If you delete all the Power BI API setting in the Azure Portal the "PowerBINotAuthorizedException" should be avoided.
Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!
Check out the September 2025 Power BI update to learn about new features.
User | Count |
---|---|
3 | |
3 | |
2 | |
2 | |
1 |
User | Count |
---|---|
11 | |
4 | |
3 | |
3 | |
3 |