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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
pborah
Impactful Individual
Impactful Individual

Get all reports within apps via Invoke-PowerBIRestMethod in powershell

I'm a workspace admin for all workspaces in our tenant and the owner of all our production apps. While we wait for our infrastructure team to authorize a service principal in AD to be able to make capacity admin level queries, I'm trying to extract data about our production apps and the reports contained within them.

 

I'm able to get apps and reports on their own but when I put things together inside a loop, things either go haywire or return nothing at all. Here's my script -

 

Connect-PowerBIServiceAccount
$path = "C:/Users/pborah/Documents/test.csv"
$apps = Invoke-PowerBIRestMethod -Url "https://api.powerbi.com/v1.0/myorg/apps" -Method Get

$Reports = 
ForEach ($app in $apps)
    {
    ForEach ($report in (Invoke-PowerBIRestMethod -Url "https://api.powerbi.com/v1.0/myorg/apps/$app.id/reports" -Method Get))
        {
        [pscustompbject]@{
            AppID = $app.id
            AppName = $app.name
            ReportID = $report.id
            ReportName = $report.name
            ReportURL = $report.webUrl
            }
        }
    }

$Reports | Export-Csv - Path $path -NoTypeInformation

 

I've tried a few different variations of this with the same results. In the first foreach loop, if I use $apps.value, code runs, but I get absolutely nothing. If I simply use $apps, I get aggregate exception and I'm not sure what's going wrong. I'm not the most advanced programmer. My primary role is that of a senior business analyst. Thank you.

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

You are using 

Invoke-PowerBIRestMethod

so you can use relative URLs

 

$apps = Invoke-PowerBIRestMethod -Url "apps" -Method Get

 

Apps don't have reports. Workspaces have reports. Do your loop across groups, not apps.

View solution in original post

1 REPLY 1
lbendlin
Super User
Super User

You are using 

Invoke-PowerBIRestMethod

so you can use relative URLs

 

$apps = Invoke-PowerBIRestMethod -Url "apps" -Method Get

 

Apps don't have reports. Workspaces have reports. Do your loop across groups, not apps.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors