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
Gow_tham
Frequent Visitor

How can I programmatically add or remove users for a Power BI dataset, given the following scenario?

I'm overhauling the RLS setup for master datasets in my organization, which has around 1000 active users. We have 9 fixed security roles, and users move between these roles monthly. While we can use existing security groups for some roles, we don't have permission to create new security groups for others. This forces us to manually add or remove members in the Power BI Service.
Creating new security groups is out of scope.

Is there a way to automate this process using APIs or PowerShell?

4 REPLIES 4
Anonymous
Not applicable

Hi, @Gow_tham 

Maybe you can use PowerShell to manage users in Power BI. Here’s a simplified example:

# Install the Power BI module
Install-Module -Name MicrosoftPowerBIMgmt

# Connect to Power BI
Connect-PowerBIServiceAccount

# Add a user to a role
Add-PowerBIRoleMember -GroupId $groupId -DatasetId $datasetId -RoleId $roleId -UserPrincipalName $userEmail

# Remove a user from a role
Remove-PowerBIRoleMember -GroupId $groupId -DatasetId $datasetId -RoleId $roleId -UserPrincipalName $userEmail

 

 You can check the following links:

vyohuamsft_0-1732590823494.png

Power BI Cmdlets reference | Microsoft Learn

 

PowerShell cmdlets, REST APIs, and .NET Client libraries for administrators - Power BI | Microsoft L...

 

How to Get Your Question Answered Quickly

Best Regards

Yongkang Hua

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

Hello @Anonymous ,

Upon testing, I received an error stating that there is no PowerShell cmdlet named AddPowerBIRoleMember. I searched for this cmdlet in the PowerShell reference links but couldn't find any reference to it. 

Note: I have installed the 
MicrosoftPowerBIMgmt PowerShell module.

Jai-Rathinavel
Super User
Super User

@Gow_tham to my knowledge there are no Rest API's or XMLA approaches to add users / members to a RLS role. It is possible to create Roles dynamically using semantic-link python library but the members cannot be added to or removed form the roles created. The best option is to have a security group for each role, but you stated it is out of scope in your current project. Not sure about the powershell route.

 

Did I answer your question. If yes, please accept my post as a solution.

 

Thanks,

Jai




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






Thanks @Jai-Rathinavel 
After checking out the community forums and talking to some MVPs, it looks like there aren't any REST APIs or PowerShell cmdlets to add users to a role programmatically (like you said). I've added this idea to the PowerBI Ideas forum. Meanwhile, I'm working on convincing my IT team/administrators to use security groups for different roles in the dataset and manage access that way. I have a PowerShell script that can add users to a security group from a CSV file. If you know any other easy ways to add users to a security group, let me know!

Cheers, 
Gowtham

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