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
NBK52
Helper I
Helper I

Change the admin access of the workspace admins to Contributer using PowerShell script

Hi All,

 

I need a PowerShell script to change the admin access of the workspace admins to Contributer.

Who all are having the Admin access to worksapce need to be changed to Contributer. I can not do manually as I have lot of workspaces.

 

Could you please assist on this.

1 ACCEPTED SOLUTION
Poojara_D12
Super User
Super User

Hi @NBK52 

Can you try this:

 

# Import Power BI Module
Import-Module MicrosoftPowerBIMgmt

# Authenticate to Power BI Service
Connect-PowerBIServiceAccount

# Retrieve all workspaces
$workspaces = Get-PowerBIWorkspace -All -Scope Organization

# Loop through each workspace
foreach ($workspace in $workspaces) {
    Write-Host "Processing Workspace: $($workspace.Name)" -ForegroundColor Yellow
    
    # Get all admins of the workspace
    $admins = Get-PowerBIWorkspaceUser -Id $workspace.Id | Where-Object { $_.AccessRight -eq "Admin" }
    
    foreach ($admin in $admins) {
        Write-Host "Changing Admin ($($admin.UserPrincipalName)) to Contributor" -ForegroundColor Cyan
        
        # Remove the admin access
        Remove-PowerBIWorkspaceUser -Id $workspace.Id -UserPrincipalName $admin.UserPrincipalName
        
        # Add the user back as a Contributor
        Add-PowerBIWorkspaceUser -Id $workspace.Id -UserPrincipalName $admin.UserPrincipalName -AccessRight Contributor
    }
}

Write-Host "All workspace admins have been updated to Contributor!" -ForegroundColor Green

 

fabric-community-super-user-fy24-25.png

Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a "Kudos"

Kind Regards,
Poojara - Proud to be a Super User
Data Analyst | MSBI Developer | Power BI Consultant
Consider Subscribing my YouTube for Beginners/Advance Concepts: https://youtube.com/@biconcepts?si=04iw9SYI2HN80HKS

View solution in original post

4 REPLIES 4
v-tsaipranay
Community Support
Community Support

Hello @NBK52 ,

Thanks for reaching out to the Microsoft fabric community forum.

It looks like

 

I would also take a moment to personally thank @Poojara_D12 , for actively participating in the community forum and for the solutions you’ve been sharing in the community forum. Your contributions make a real difference.

 

Based on his response, it is indeed your task to change the admin access of workspace admins to contributor. The code involves all workspace IDs. Additionally, I wanted to mention that we can also use specific workspace IDs for changing the admin to contributor. Please use the following code to achieve this:

 

Import-Module MicrosoftPowerBIMgmt
Connect-PowerBIServiceAccount

Get-PowerBIWorkspace

$workspaceId = "<Your-Workspace-ID>"
$admins = @("<Admin-Email1>", "<Admin-Email2>")

foreach ($admin in $admins)

{

Remove-PowerBIWorkspaceUser -Id $workspaceId -UserEmailAddress $admin

Add-PowerBIWorkspaceUser -Id $workspaceId -UserEmailAddress $admin -AccessRight Contributor

}

vtsaipranay_1-1738000136353.png

 

For your better understanding, I am including a documentation link. Please refer to it:

Add-PowerBIWorkspaceUser (MicrosoftPowerBIMgmt.Workspaces) | Microsoft Learn

 

I hope my suggestions give you good ideas, if you need any further assistance, feel free to reach out.

 

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

 

Thank you. 

 

 

 

Thank you for providing..Can this be done like changing permissions from admin to contributor for the Workspaces read from a CSV as we have lot of workspaces and we need to do some batch wise.

Poojara_D12
Super User
Super User

Hi @NBK52 

Can you try this:

 

# Import Power BI Module
Import-Module MicrosoftPowerBIMgmt

# Authenticate to Power BI Service
Connect-PowerBIServiceAccount

# Retrieve all workspaces
$workspaces = Get-PowerBIWorkspace -All -Scope Organization

# Loop through each workspace
foreach ($workspace in $workspaces) {
    Write-Host "Processing Workspace: $($workspace.Name)" -ForegroundColor Yellow
    
    # Get all admins of the workspace
    $admins = Get-PowerBIWorkspaceUser -Id $workspace.Id | Where-Object { $_.AccessRight -eq "Admin" }
    
    foreach ($admin in $admins) {
        Write-Host "Changing Admin ($($admin.UserPrincipalName)) to Contributor" -ForegroundColor Cyan
        
        # Remove the admin access
        Remove-PowerBIWorkspaceUser -Id $workspace.Id -UserPrincipalName $admin.UserPrincipalName
        
        # Add the user back as a Contributor
        Add-PowerBIWorkspaceUser -Id $workspace.Id -UserPrincipalName $admin.UserPrincipalName -AccessRight Contributor
    }
}

Write-Host "All workspace admins have been updated to Contributor!" -ForegroundColor Green

 

fabric-community-super-user-fy24-25.png

Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a "Kudos"

Kind Regards,
Poojara - Proud to be a Super User
Data Analyst | MSBI Developer | Power BI Consultant
Consider Subscribing my YouTube for Beginners/Advance Concepts: https://youtube.com/@biconcepts?si=04iw9SYI2HN80HKS

Thank you for providing!! and in the provided script how can we exclude user personal workspaces..But I need do for testing for some of specific workspaces before doing it all..can this be done using workspace IDs or any..changing the admin to contributer on some of specific workspaces

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.