cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted

PowerShell REST APIs - getting list of all reports in the tenant

Hi all, hopefully last noob question on how to best use the REST APIs. I have a requirement I thought would be simple: "list all reports in the entire tenant, and which workspace they live in".

 

My current code is:

 

$Workspaces = Get-PowerBIWorkspace -Scope Organization -All

$Reports =
ForEach ($workspace in $Workspaces)
    {
    Write-Host $workspace.Name
    ForEach ($report in (Get-PowerBIReport -Scope Organization -WorkspaceId $workspace.Id))
        {
        [pscustomobject]@{
            WorkspaceID = $workspace.Id
            WorkspaceName = $workspace.Name
            ReportID = $report.Id
            ReportName = $report.Name
            ReportURL = $report.WebUrl
            ReportDatasetID = $report.DatasetId
            }
        }
    }
$Reports | Export-Csv -Path $logpath -NoTypeInformation

The script runs...but I'm hitting several issues I'm not sure how to work around:

1.  I seem to be seeing reports that were deleted months ago...and there doesn't appear to be an attribute I can use to filter those out

2. I'm still researching this - but it appears that for reports that are shared, each user is getting a "copy" of the report in their own workspace (or at least the script above is showing that). There also doesn't appear to be a way to filter these out from "real" reports a user created in their own workspace...if I exclude personal workspaces then I loose visibility into ALL user created reports, not just "shared" ones. I did find a code snippet that suggests filtering down to reports where "isOwnedByMe" = TRUE, but the "isOwnedByMe" attribute doesn't show up when an admin lists all the reports...only when a user lists their own reports

 

This seemed like it was going to be so easy...but obviously not so much. I appreciate any help / insights in to how to work around around this - thank you!

 

Scott

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

Re: PowerShell REST APIs - getting list of all reports in the tenant

Dear Scott,

 

Not sure if anyone has gotten back to you, or if you've solved it yourself, but I recently set up a Tenancy overview report using the Power Shell cmdlets and rest API in Power BI and noticed teh same.

 

With a bit of investigation i noticed that they aren't acutally DELETED reports, they're Reports that have been Published via APPS as the Report ID and Dataset ID are different to the Reports stored in the Workspace. This is because different versions can exist in both spaces, and an App report doesn't automatically get replaced when publishing a new report to a workspace. 

 

I found this out by using the cmdlet Invoke-PowerBIRestMethod -url 'Apps' -Method Get to retrieve published apps and their reports. 

It's also worth noting that this only occurs when using the -scope Organization on Get-Reports. 

 

The way i dealt with this was those ReportID's that matched when using the invoke-powerbirestmethod were published reports and datasets, those that didn't were Workspace Reports (unpublished). This gave me a much cleaner overview of the tenancy.

 

Hope this helps.


Chris

View solution in original post

2 REPLIES 2

Re: PowerShell REST APIs - getting list of all reports in the tenant

Dear Scott,

 

Not sure if anyone has gotten back to you, or if you've solved it yourself, but I recently set up a Tenancy overview report using the Power Shell cmdlets and rest API in Power BI and noticed teh same.

 

With a bit of investigation i noticed that they aren't acutally DELETED reports, they're Reports that have been Published via APPS as the Report ID and Dataset ID are different to the Reports stored in the Workspace. This is because different versions can exist in both spaces, and an App report doesn't automatically get replaced when publishing a new report to a workspace. 

 

I found this out by using the cmdlet Invoke-PowerBIRestMethod -url 'Apps' -Method Get to retrieve published apps and their reports. 

It's also worth noting that this only occurs when using the -scope Organization on Get-Reports. 

 

The way i dealt with this was those ReportID's that matched when using the invoke-powerbirestmethod were published reports and datasets, those that didn't were Workspace Reports (unpublished). This gave me a much cleaner overview of the tenancy.

 

Hope this helps.


Chris

View solution in original post

Re: PowerShell REST APIs - getting list of all reports in the tenant

Hi Chris - I appreciate the insight. I'll take a look and see if our data is showing up similar to what you describe. I'm honestly finding it very difficult to use the APIs and the audit logs - it seems like Microsoft keeps updating / changing the structure, which makes it almost impossible to produce reports which work across history.

 

Thanks very much for the lead, I'll play with this next week and see what comes out of it (and will update this thread so hopefully others can find this info easier).

 

Thanks again!

Scott

Helpful resources

Announcements
New Ranks and Rank Icons in 2020

New Ranks and Rank Icons in 2020

Read the announcement for more information!

New Kudos Given Badges Coming

New Kudos Given Badges Coming

We're rolling out new Kudos Given badges. Find out how many Kudos you've given.

November 2019 Community Highlights

November 2019 Community Highlights

Get an overview of the events and great community content from November.

Power Platform World Tour

Power Platform World Tour

Find out where you can attend!

Top Solution Authors
Top Kudoed Authors (Last 30 Days)