This PowerShell script lists all Power BI workspaces (1) in your organization, along with the access/membership list (2). The members User Principal Name (UPN) and their permission are listed and includes users, groups and app identities.
- The script starts by importing the
MicrosoftPowerBIMgmt
module, which provides the cmdlets needed to interact with Power BI. - It then logs into Power BI and connects to the Power BI service account.
- The script retrieves all workspaces in the organization using the
Get-PowerBIWorkspace
cmdlet. - It creates an empty array to store the results.
- The script then iterates over each workspace, and for each workspace, it iterates over each user.
- For each user, it creates a new PowerShell object with the properties we're interested in:
WorkspaceName
,WorkspaceId
,WorkspaceType
,WorkspaceState
,MemberUserIdentifier
,MemberPrincipleType
,MemberUserPrincipalName
, andMemberAccessRight
. - It adds this object to the results array.
- Finally, the script exports the results to a CSV file named
PowerBIWorkspaceUsers.csv
. The CSV file includes headers for each property, and each row in the CSV file represents a user in a workspace.
- Open PowerShell.
- Navigate to the directory where the script is located.
- Run the script by typing
.\PowerBI-Workspaces.ps1
and pressing Enter. - The script will prompt you to log into Power BI. Enter your credentials.
- The script will run and create a CSV file named
PowerBIWorkspaceUsers.csv
in the current directory.
- PowerShell
- The
MicrosoftPowerBIMgmt
PowerShell module. You can install it by runningInstall-Module -Name MicrosoftPowerBIMgmt
in PowerShell. - A Power BI account with the necessary permissions to list workspaces and their users.