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

Permission Change on Power BI workspaces

Hi All,

 

We have a list of workspaces along with workspaces ids in CSV file. Whoever is Admin access to these all workspaces need to be converted to contribute permission though PowerShell script. 

 

Kindly suggest. let me know if any details are required.

 Thanks.

2 ACCEPTED SOLUTIONS

I already provided the details. Remove the admins, add the contributors.

View solution in original post

Poojara_D12
Super User
Super User

Hi @NBK52 

To update Power BI workspace permissions using PowerShell, first, import the Power BI module and authenticate using Login-PowerBI. Then, load the CSV file containing workspace IDs and names. For each workspace, retrieve the list of users with "Admin" access using Get-PowerBIWorkspace. Loop through these users, remove their "Admin" role using Remove-PowerBIWorkspaceUser, and assign them "Contributor" access using Add-PowerBIWorkspaceUser. Ensure you have Power BI admin permissions to execute these changes. The script can be modified to exclude certain users or log changes for tracking. Additionally, automation can be achieved using a service principal instead of interactive login. Always review permissions before running the script to prevent accidental access modifications.

 

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

12 REPLIES 12
v-nmadadi-msft
Community Support
Community Support

Hi @NBK52 ,

As we haven’t heard back from you, we wanted to kindly follow up to check if the solution provided by the community members for the issue worked. If our response addressed, please mark it as Accept as solution and click Yes if you found it helpful.

 

Thanks and regards

v-nmadadi-msft
Community Support
Community Support

Hi @NBK52,

I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If my response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.


Thank you.

v-nmadadi-msft
Community Support
Community Support

Hi @NBK52 

May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. If you've found another step that worked, feel free to share it and mark it as the solution. This will help others to gain additional insights and benefit from your experience and will be helpful for other community members who have similar problems to solve it faster.

Thank you.

NBK52
Helper I
Helper I

I have used below script for the same requirement and have the data in excel like below 

WorkspaceId,WorkspaceName
<workspace_id_1>,<workspace_name_1>
<workspace_id_2>,<workspace_name_2>

 

# Import the Power BI module
Import-Module MicrosoftPowerBIMgmt

# Authenticate to Power BI
Login-PowerBI

# Load the CSV file containing workspace IDs and names
$workspaces = Import-Csv -Path "C:\Temp\Myworkspaces.csv"

# Loop through each workspace
foreach ($workspace in $workspaces) {
$workspaceId = $workspace.WorkspaceId
$workspaceName = $workspace.WorkspaceName

# Retrieve the list of users with "Admin" access
$adminUsers = Get-PowerBIWorkspace -Id $workspaceId -Scope Organization |
Get-PowerBIWorkspaceUser |
Where-Object { $_.AccessRight -eq 'Admin' }

# Loop through each admin user
foreach ($adminUser in $adminUsers) {
$userEmail = $adminUser.EmailAddress

# Remove "Admin" role
Remove-PowerBIWorkspaceUser -Id $workspaceId -User PrincipalName $userEmail -Confirm:$false

# Assign "Contributor" role
Add-PowerBIWorkspaceUser -Id $workspaceId -User PrincipalName $userEmail -AccessRight Contributor
}
}

# Logout from Power BI
Logout-PowerBI

 

But got this below error. Please sugest.

 

Get-PowerBIWorkspaceUser : The term 'Get-PowerBIWorkspaceUser' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the
name, or if a path was included, verify that the path is correct and try again.

Users, not User. Iterate over the list.

v-nmadadi-msft
Community Support
Community Support

Hi @NBK52  ,
Thanks for reaching out to the Microsoft fabric community forum.
You can use this following PowerShell script to loop through the CSV file like you want to get the workspace id’s

 

$csvfile = Import-CSV -Path " CSV file path "
foreach( $row in $csvfile){ Write-Output "workspace_id: $($row.workspace_id)"}

 


Once you retrieve the workspace ID's

As mentioned by @lbendlin  , @Poojara_D12  please follow the document to change the permission of admins to contributor. 


If you find this post helpful, please mark it as an "Accept as Solution" and consider giving a KUDOS.
Thanks and Regards

Poojara_D12
Super User
Super User

Hi @NBK52 

To update Power BI workspace permissions using PowerShell, first, import the Power BI module and authenticate using Login-PowerBI. Then, load the CSV file containing workspace IDs and names. For each workspace, retrieve the list of users with "Admin" access using Get-PowerBIWorkspace. Loop through these users, remove their "Admin" role using Remove-PowerBIWorkspaceUser, and assign them "Contributor" access using Add-PowerBIWorkspaceUser. Ensure you have Power BI admin permissions to execute these changes. The script can be modified to exclude certain users or log changes for tracking. Additionally, automation can be achieved using a service principal instead of interactive login. Always review permissions before running the script to prevent accidental access modifications.

 

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

Hi @Poojara_D12 , @lbendlin 

Can this blow script can be modified to change the workspace admins to contriburer from the list of CSV files. I am new to PowerShell script..need your assistance.

 

I have the data in excel like below 

WorkspaceId,WorkspaceName
<workspace_id_1>,<workspace_name_1>
<workspace_id_2>,<workspace_name_2>

 

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

}

lbendlin
Super User
Super User

That would leave you without workspace admins?

 

Use Remove and Add

 

Add-PowerBIWorkspaceUser (MicrosoftPowerBIMgmt.Workspaces) | Microsoft Learn

Yes, That woud leave without Admins..Workspace Admins already there for each Workflow but we need to change who are having admin permission to workspaces to contribute.

 

We have list of workspaces and workspaces ids in CSV file, Now we want to change whoever having the admin permission to those users to contribute through PowerShell script.

 

We need to do it in bulk hence required PowerShell script that read data from CSV file and change the permission

 

Can this be done?. Let us know if any details required

I already provided the details. Remove the admins, add the contributors.

Can this be done bulk at a time for all workspeces in CSV files 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.