Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Getting 401 error while powerBImanagement cmdlets in PowerShell

While runing below script in power shell i am receiving 401 error using service principal 

Ynr0225_0-1669393863309.png

Ynr0225_1-1669393911301.png

For tracing the error i ran the command Resolve-PowerBIError -Last and i got the complete error detail as shown below

Ynr0225_2-1669394027942.png

 

 

Service principal having below API permissions 

Ynr0225_3-1669394191183.png

In Power BI admin portal under tenant settings we have enabled below options also

Ynr0225_4-1669394314763.png

I think all the required API premissions and options enabled in tenant settings but i am still receiving the 401 error. Could anyone help me on this issue. Thanks in advance!

2 REPLIES 2
Anonymous
Not applicable

Hi @Anonymous ,

 

Way1:You may check if you call an admin API as a regular user without admin rights? As expected, PowerShell will display an error message informing you that the call was unauthorized
You can refer to the following link:

Working with PowerShell in Power BI | Microsoft Power BI Blog | Microsoft Power BI

Way2: Which way do you use for authentication, maybe it’s affected by your authentication.

You can refer to the following link:

Solved: Power Bi REST API - 401 Authorization error when u... - Microsoft Power BI Community

Best Regards,

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

tackytechtom
Super User
Super User

Hi @Anonymous ,

 

On the Allow Service Principal to use Power BI APIs, it says "enabled for the subset of the organization". You can specify security groups in their which are allowed to use the REST APIs. Is your service principal laying in such a security group?

 

/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/



Did I answer your question➡️ Please, mark my post as a solution ✔️

Also happily accepting Kudos 🙂

Feel free to connect with me on LinkedIn! linkedIn

#proudtobeasuperuser 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.