power-bi-report-server

How can you retreive all the reports which use row-level security on a Power BI Report Server?


For example in the SQL view [PBIRS].[dbo].[ExecutionLog3] you can find the logging, but I haven't found any table or view with a boolean or something to indicate that Row-level security is in use. Where can I find that for all the 300+ reports at once?

enter image description here


Solution

  • In the end I received a clue to the answer here: https://community.fabric.microsoft.com/t5/Report-Server/Retreive-the-use-of-Row-level-security/m-p/3896924#M34829 With that I was able to make below loop;

    # Define variables
    $webPortalURL = "https://example.com/ReportsPowerBI"
    $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 {
    
        }
    }