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
Ramsay_Bolton
New Member

How to grant user to workspaces as a Fabric Admin

I tried to run the Powershell script below to add a user to all active workspaces, but the script fails returning the "unauthorized" status code. I am running the script having signed into the Power Bi Management modules as my Fabric Admin account (after signign in with Connect-PowerBIServiceAccount). 

 

The script successully gets all relevant workspaces, it just doesn't add the user.

 

The fabric administrator doesn't have access to the workspaces, but having the global Fabric Administrator role it can add users to workspaces in the admin portal (but I need an automated approach)

 

$workspaces = Get-PowerBIWorkspace -Scope Organization | Where {($_.State -eq "Active") -and ($_.Type -eq "Workspace")}
##$workspaces

$user = "Username@domain.co.uk"

foreach($workspace in $workspaces)
{
Write-Host "Adding User to : " $workspace.Name
try
{
Add-PowerBIWorkspaceUser -Id $workspace.Id -UserPrincipalName $user -AccessRight Contributor
}
catch
{
Write-Host "Message: [$($_.Exception.Message)"] -ForegroundColor Red
}
}

 

What do I need to do to run a script like this; I need it to add a specific user to all workspaces that are active / of the type "workspace" as per my filters. There is no one account that has access, so I believe I need to run it as a fabric administrator

 

 

1 ACCEPTED SOLUTION
ibarrau
Super User
Super User

Hi. I work a lot with Power Bi Rest API, not specifically with powershell. However, I can deduce that it won't work. Being Fabric Administration only means you can use the Admin rest api or in this case the MicrosoftPowerBiMgmt.Admin. That would be the benefit. All other requests outside the admin work for any user. The way they work is that it let's the account opperate what the requests if they really have access to the resources. That means the MicrosoftPowerBiMgmt.Workspaces will only work with the workspaces the account logged in can actually see. If you want to add users to a workspace as Fabric Administrator, you should try this api request that it's under admin category: https://learn.microsoft.com/en-us/rest/api/power-bi/admin/groups-add-user-as-admin

That one should work without unauthorized.

I hope that helps,


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

Happy to help!

LaDataWeb Blog

View solution in original post

4 REPLIES 4
v-priyankata
Community Support
Community Support

Hi @Ramsay_Bolton 

Thank you for reaching out to the Microsoft Fabric Forum Community.
@ibarrau  Thanks for your inputs.

I hope the information provided by users was helpful. If you still have questions, please don't hesitate to reach out to the community.

 

 

Hi @Ramsay_Bolton 

I wanted to check if you had the opportunity to review the information provided by users. Please feel free to contact us if you have any further questions.

Hi @Ramsay_Bolton 

Hope everything’s going smoothly on your end. I wanted to check if the issue got sorted. if you have any other issues please reach community.

ibarrau
Super User
Super User

Hi. I work a lot with Power Bi Rest API, not specifically with powershell. However, I can deduce that it won't work. Being Fabric Administration only means you can use the Admin rest api or in this case the MicrosoftPowerBiMgmt.Admin. That would be the benefit. All other requests outside the admin work for any user. The way they work is that it let's the account opperate what the requests if they really have access to the resources. That means the MicrosoftPowerBiMgmt.Workspaces will only work with the workspaces the account logged in can actually see. If you want to add users to a workspace as Fabric Administrator, you should try this api request that it's under admin category: https://learn.microsoft.com/en-us/rest/api/power-bi/admin/groups-add-user-as-admin

That one should work without unauthorized.

I hope that helps,


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

Happy to help!

LaDataWeb Blog

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors