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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
jlwkok
Advocate I
Advocate I

Retreive the use of Row-level security

Can you get this data for all reports at once from the PBIRS database or via a PowerShell request?

This is regarding more than 400 reports and that's why I'm looking for an automated solution/query.

 

PBIRS Row-level security.png

1 ACCEPTED SOLUTION
sarada
Frequent Visitor

powershell script you can use to get rls for one report:

$ReportServerUri = "https://<server_name>/PBIReports
#API to get roles and role assignments
$RoleAssignmentsPath = $ReportServerUri + "/api/v2.0/PowerBIReports(Path='<ReportPath>')/DataModelRoleAssignments"
$RolesPath = $ReportServerUri + "/api/v2.0/PowerBIReports(Path='<ReportPath>')/DataModelRoles"

#call API - row level security
$RoleAssignments = Invoke-RestMethod -Uri $RoleAssignmentsPath -ContentType "application/json" -UseDefaultCredentials -Method Get
#call API - RLS role
$Roles = Invoke-RestMethod -Uri $RolesPath -ContentType "application/json" -UseDefaultCredentials -Method Get

 

note that in above script if your report is in root folder of PBIRS portal then  <ReportPath>  is /report_name
hope this fix your issue!   

View solution in original post

3 REPLIES 3
sarada
Frequent Visitor

powershell script you can use to get rls for one report:

$ReportServerUri = "https://<server_name>/PBIReports
#API to get roles and role assignments
$RoleAssignmentsPath = $ReportServerUri + "/api/v2.0/PowerBIReports(Path='<ReportPath>')/DataModelRoleAssignments"
$RolesPath = $ReportServerUri + "/api/v2.0/PowerBIReports(Path='<ReportPath>')/DataModelRoles"

#call API - row level security
$RoleAssignments = Invoke-RestMethod -Uri $RoleAssignmentsPath -ContentType "application/json" -UseDefaultCredentials -Method Get
#call API - RLS role
$Roles = Invoke-RestMethod -Uri $RolesPath -ContentType "application/json" -UseDefaultCredentials -Method Get

 

note that in above script if your report is in root folder of PBIRS portal then  <ReportPath>  is /report_name
hope this fix your issue!   

Great, thank you! With your example I was able to make below loop and got all of them.

 

# Define variables
$PBI_Reports_Array = @()
$PBI_Reports_Array = $(Invoke-RestMethod -UseDefaultCredentials -uri $($webPortalURL + "/api/v2.0/PowerBIReports"))
$loopCount = 0 
$RoleAssignments = @()
# Loop through all Power BI reports 
foreach ($reportPath in $PBI_Reports_Array.value.path) {
    try {
$RoleAssignmentsPath = $ReportServerUri + "/api/v2.0/PowerBIReports(Path='" + $reportPath + "')/DataModelRoleAssignments";
$RolesPath = $ReportServerUri + "/api/v2.0/PowerBIReports(Path='" + $reportPath + "')/DataModelRoles";
#call API - row level security
$RoleAssignments += $(Invoke-RestMethod -Uri $RoleAssignmentsPath -ContentType "application/json" -UseDefaultCredentials -Method Get);
#call API - RLS role
#$Roles = Invoke-RestMethod -Uri $RolesPath -ContentType "application/json" -UseDefaultCredentials -Method Get
 
        if ([string]::IsNullOrEmpty($($RoleAssignments[$loopCount].value))) { 
            write-host "$loopCount | $reportPath | No DataModelRoleAssignments for this report!"; 
        }
        else {
            write-host "$loopCount | $reportPath | $($RoleAssignments[$loopCount].value.GroupUserName)" -foregroundcolor magenta;
        }
 
        $loopCount++;
    }
    catch {
 
    }
}
Anonymous
Not applicable

Hi @jlwkok ,

You configure RLS for reports imported into Power BI with Power BI Desktop. You can also configure RLS on reports that use DirectQuery, such as SQL Server. Keep in mind that RLS isn't respected if your DirectQuery connection uses integrated authentication for report readers. For Analysis Services live connections, you configure row-level security on the on-premises model. The security option doesn't show up for live connection datasets.

 

For more details, you could read related document: Row-level security (RLS) in Power BI Report Server - Power BI | Microsoft Learn

 

Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

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