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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Powershell script error - Unauthorized

 Hi,

 

I have Power BI administrator role in my organization. I want to view how many workspaces have been created, therefore I was running the simple below  Powershell script :

 

Login-PowerBIServiceAccount

$groups  =  Get-PowerBIGroup -Scope Organization -All

$groups

  

While running the script I am getting error below error:

Workspace_Error.PNG

  Am I missing any other admin rights to extract the information of Power BI Service ?

5 REPLIES 5
Anonymous
Not applicable

Hi @Anonymous,

I think Watsky means the general organization and gov/national organization. The gov/national should be different from the common organization.

In addition, the rest API is required to enable the permissions. Have you checked the account include the corresponding permissions and scopes that API required?

Power BI REST APIs for embedded analytics and automation - Power BI REST API | Microsoft Docs

Microsoft identity platform scopes, permissions, & consent | Microsoft Docs

Regards,
Xiaoxin Sheng

Anonymous
Not applicable

Hi @Watsky ,

 

Thank you for the reply. Can you explain what is "regular commercial environment" ? And how do I know what are options we have for -Environment similar to "USGov" ?

 

Regards,

ankbaner

When you log into the Power BI service what is the url that you're connecting to? Is it app.powerbi.com or is it something else? These are the options as show via Power Shell:

Watsky_0-1640872560428.png

 


Did my answer(s) help you? Give it a kudos by clicking the Thumbs Up!
Did my post answer your question(s)? Mark my post as a solution. This will help others find the solution.

Proud to be a Super User!

Anonymous
Not applicable

Hi @Watsky ,

 

Yes I am connecting to app.powerbi.com from Finland. I tried 3 options from "-Environment" i.e. Custom, Germany and Public but neither of the options worked.

 

 

Watsky
Solution Sage
Solution Sage

Hey @Anonymous ,

One (1) thought, do you work in the regular commerical environment? If your tenant is not in the regular commerical Power BI environment then you would need to set your environment. For instance, I work in GCC so I have to set my environment as such:

Login-PowerBIServiceAccount -Environment USGov

 


Did my answer(s) help you? Give it a kudos by clicking the Thumbs Up!
Did my post answer your question(s)? Mark my post as a solution. This will help others find the solution.

Proud to be a Super User!

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.