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

Removing multiple users form the power bi workspace using powershell script

Hi All,

 

I have a list of workspaces and user names in one csv file and i need to remove that individual users from the workspace who are in that excel file. Remove in Power BI service taking time. So by using that CSV file i need to remove multiple users using PowerShell script. If it is possible please share the sctipt. Thanks in advance!

1 ACCEPTED SOLUTION

Hi @Anonymous ,

 

You can get the respective WorkspaceID as decribed here:

PowerShell Gallery | functions/Get-Workspace.ps1 0.2.0

 

/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/



Did I answer your question➡️ Please, mark my post as a solution ✔️

Also happily accepting Kudos 🙂

Feel free to connect with me on LinkedIn! linkedIn

#proudtobeasuperuser 

View solution in original post

3 REPLIES 3
tackytechtom
Super User
Super User

Hi  @Anonymous, 

 

Yes, it is possible to use a PowerShell script to remove multiple users from a Power BI workspace. To do this, you can use the Remove-PowerBIWorkspaceUser cmdlet, which is part of the Power BI PowerShell module.

Here is an example of a script that you can use to remove multiple users from a PowerBI workspace using a CSV file:

 

# Import the Power BI module
Import-Module -Name MicrosoftPowerBIMgmt # Connect to Power BI Connect-PowerBI # Set the path to the CSV file containing the list of workspaces and user names $csvFilePath = "C:\path\to\file.csv" # Read the CSV file into a variable $users = Import-Csv -Path $csvFilePath # Loop through the rows in the CSV file foreach ($user in $users) { # Get the workspace ID and user name from the current row $workspaceId = $user.WorkspaceId $userName = $user.UserName # Remove the user from the workspace Remove-PowerBIWorkspaceUser -WorkspaceId $workspaceId -UserName $userName }

 

In this script, the CSV file is assumed to have two columns: "WorkspaceId" and "UserName". The script reads the CSV file into a variable, and then loops through the rows in the file, extracting the workspace ID and user name for each row. The Remove-PowerBIWorkspaceUser cmdlet is then called for each row, passing in the workspace ID and user name as arguments, to remove the user from the workspace.

 

Let me know if this works 🙂

 

/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/



Did I answer your question➡️ Please, mark my post as a solution ✔️

Also happily accepting Kudos 🙂

Feel free to connect with me on LinkedIn! linkedIn

#proudtobeasuperuser 

Anonymous
Not applicable

Hi @tackytechtom,

Thanks for the response! I ran above Power shell script and its working fine but my workaround will be CSV file that contain Workspace Name instead of Workspave ID and users name. Is it possible to remove users with the above script that contains workspace name and users name in the csv file.

 

Hi @Anonymous ,

 

You can get the respective WorkspaceID as decribed here:

PowerShell Gallery | functions/Get-Workspace.ps1 0.2.0

 

/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/



Did I answer your question➡️ Please, mark my post as a solution ✔️

Also happily accepting Kudos 🙂

Feel free to connect with me on LinkedIn! linkedIn

#proudtobeasuperuser 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

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.