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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

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
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.