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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
mangchaaBI
Helper II
Helper II

List All Data Source / Database / Tables/Views Used

Hi everyone,

 

I have multiple pBI reports created and I'm being asked by my team to list all datasource, tables, queries I used on my pBI reports

I usually connect to our SQL instance when creating the queries, so it would help a lot if there's a way to list all the queries I created into a single view, important information would be the datasource, the database and the table/view that was used in the query

 

Thanks again

1 ACCEPTED SOLUTION

The snippet is using an array operation that is O(n). If the amount of rows is a big number this will slow down to a crawl. Changing it to be a hash table should speed the collection up a bit. 

$datasource_hashTable = @{}

$pbidatasource = Get-PowerBIDatasource -DatasetId {INSERT ID}

foreach ($datasource in $pbidatasource) {
    $datasource_row = @{
        "Name"                = $datasource.name
        "ConnectionString"    = $datasource.ConnectionString
        "ConnectionServer"    = $datasource.ConnectionDetails.Server
        "ConnectionDatabase"  = $datasource.ConnectionDetails.Database
        "ConnectionUrl"       = $datasource.ConnectionDetails.Url
        "GatewayID"           = $datasource.GatewayId
        "Datasoruceid"        = $datasource.DatasourceId
    }
    $datasource_hashTable[$datasource.DatasourceId] = $datasource_row
}

 

You could also use the graph api and python (which has pandas), that might be even faster.

View solution in original post

7 REPLIES 7
amitchandak
Super User
Super User

@mangchaaBI , One option is to use power bi cmdlets

https://learn.microsoft.com/en-us/powershell/module/microsoftpowerbimgmt.data/get-powerbidatasource?...

 

How to use

https://learn.microsoft.com/en-us/powershell/power-bi/overview?view=powerbi-ps

 

You can also view all connections in the power bi service lineage view of dataset

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

hi @amitchandak this is the only result that I'm getting, am I doing it wrong? 

 

mangchaaBI_0-1681378882726.png

 

Hi, 

The connectiondetails is an array so you have to either use a hash table or unpack it. 

 

This example will do that. 

$datasource_array = @()
$pbidatasource = Get-PowerBIDatasource -DatasetId {INSERT ID}
        
            foreach($datasource in $pbidatasource){

                $datasource_row = New-Object psobject -property @{
                    "Name" = $datasource.name
                    "ConnectionString" = $datasource.ConnectionString
                    "ConnectionServer" = $datasource.ConnectionDetails.Server
                    "ConnectionDatabase" = $datasource.ConnectionDetails.Database
                    "ConnectionUrl" = $datasource.ConnectionDetails.Url
                    "GatewayID" = $datasource.GatewayId
                    "Datasoruceid" = $datasource.DatasourceId

                }
                $datasource_array += $datasource_row
            }

 

Anonymous
Not applicable

Works but VERY slow across 45,000 Datasets and 47,000 datasources. Also, to see all of yours, you need to add -Scope Organization but only if you are a Fabric Admin.

The snippet is using an array operation that is O(n). If the amount of rows is a big number this will slow down to a crawl. Changing it to be a hash table should speed the collection up a bit. 

$datasource_hashTable = @{}

$pbidatasource = Get-PowerBIDatasource -DatasetId {INSERT ID}

foreach ($datasource in $pbidatasource) {
    $datasource_row = @{
        "Name"                = $datasource.name
        "ConnectionString"    = $datasource.ConnectionString
        "ConnectionServer"    = $datasource.ConnectionDetails.Server
        "ConnectionDatabase"  = $datasource.ConnectionDetails.Database
        "ConnectionUrl"       = $datasource.ConnectionDetails.Url
        "GatewayID"           = $datasource.GatewayId
        "Datasoruceid"        = $datasource.DatasourceId
    }
    $datasource_hashTable[$datasource.DatasourceId] = $datasource_row
}

 

You could also use the graph api and python (which has pandas), that might be even faster.

Hi @gramc,
Could you explain what this code is and how to use it.
At least a couple of sentences to understand the direction of the way.
Thanks!

hi, 

You can see the cmdlet documentation here: https://learn.microsoft.com/en-us/powershell/power-bi/overview?view=powerbi-ps,

 

You will need to install the Power BI cmdlets and log in to the Power BI service.

This script retrieves all connection details for a specified dataset. After you have logged on to the service and gotten the list of ids to loop through.

 

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors