Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
ajaquib
Frequent Visitor

Export User name and User access into CSV using Power Shell

Hi All,

 

Is it possible to export user name and user access role for a workspace with help of Power shell script.

1 ACCEPTED SOLUTION
amustafa
Solution Sage
Solution Sage

Assuming you are familier with the PowerBI PowerShell cmdlets...

 

# Import the required module
Import-Module MicrosoftPowerBIMgmt

# Provide your PowerBI credentials
$username = "your_username"
$password = "your_password" | ConvertTo-SecureString -asPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential ($username, $password)

# Connect to PowerBI service account
Connect-PowerBIServiceAccount -Credential $credential | Out-Null

# Get the workspace
$workspace = Get-PowerBIWorkspace -Name "Your Workspace Name" -Scope Organization

# Create an empty array to hold the results
$results = @()

# Loop through each user in the workspace
foreach ($user in $workspace.Users) {
# Create a custom object for each user
$userObj = New-Object PSObject -Property @{
Identifier = $user.Identifier
AccessRight = $user.AccessRight
PrincipalType = $user.PrincipalType
}
# Add the custom object to the results array
$results += $userObj
}

# Export the results to a CSV file
$results | Export-Csv -Path "C:\path\to\yourfile.csv" -NoTypeInformation

# Disconnect from PowerBI service account
Disconnect-PowerBIServiceAccount

 

 





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

Proud to be a Super User!




View solution in original post

1 REPLY 1
amustafa
Solution Sage
Solution Sage

Assuming you are familier with the PowerBI PowerShell cmdlets...

 

# Import the required module
Import-Module MicrosoftPowerBIMgmt

# Provide your PowerBI credentials
$username = "your_username"
$password = "your_password" | ConvertTo-SecureString -asPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential ($username, $password)

# Connect to PowerBI service account
Connect-PowerBIServiceAccount -Credential $credential | Out-Null

# Get the workspace
$workspace = Get-PowerBIWorkspace -Name "Your Workspace Name" -Scope Organization

# Create an empty array to hold the results
$results = @()

# Loop through each user in the workspace
foreach ($user in $workspace.Users) {
# Create a custom object for each user
$userObj = New-Object PSObject -Property @{
Identifier = $user.Identifier
AccessRight = $user.AccessRight
PrincipalType = $user.PrincipalType
}
# Add the custom object to the results array
$results += $userObj
}

# Export the results to a CSV file
$results | Export-Csv -Path "C:\path\to\yourfile.csv" -NoTypeInformation

# Disconnect from PowerBI service account
Disconnect-PowerBIServiceAccount

 

 





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

Proud to be a Super User!




Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.