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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
momo_man
Frequent Visitor

powershell command to get datasource name is not working

Below is my code to try and get the datasource names for all the datasources for every report in my power bi service. It is the workspace and dataset correctly but it is not getting the datasource name correctly. for datasource name it just returns a blank like so, "Datasource: ". But what it does do correctly is return the number of Datasources. So, for example if a report has 3 datasources it will return "Datasource: " 3 times. Any help would be very appreciated. 

 

Install-Module -Name MicrosoftPowerBIMgmt.Data
Login-PowerBI


# Fetch all workspaces

$workspaces = Get-PowerBIWorkspace

 

foreach ($workspace in $workspaces) {

   Write-Output "Workspace: $($workspace.Name)"

 

   # Get datasets for each workspace

   $datasets = Get-PowerBIDataset -WorkspaceId $workspace.Id

   foreach ($dataset in $datasets) {

       Write-Output "  Dataset: $($dataset.Name)"

 

       # Get datasources for each dataset in the current workspace

       $datasources = Get-PowerBIDatasource -DatasetId $dataset.Id -WorkspaceId $workspace.Id

       foreach ($datasource in $datasources) {

           Write-Output "    DataSource: $($datasource.Name)"

       }

   }

}

1 ACCEPTED SOLUTION
momo_man
Frequent Visitor

thank yall for the replies it turns out it was a permissions thing

 

View solution in original post

5 REPLIES 5
momo_man
Frequent Visitor

thank yall for the replies it turns out it was a permissions thing

 

GilbertQ
Super User
Super User

Hi @momo_man 

 

Why do you not use the Power BI Scanner which will get all this information and more?

 

https://powerbi.tips/2021/10/using-the-power-bi-scanner-api-to-manage-tenants-entire-metadata/





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!







Power BI Blog

Any idea how you would find the datasource names from the scan? I can't find it 😞

Maybe I will try this. I was trying to do this in less steps. Avoiding any azure interaction with api's with the module. If it worked it would serve its purpose. I just am trying to get the names of all datasources being used in my power bi service

foodd
Super User
Super User

Hello @momo_man, and thank you for starting a conversation in the Service Forum.    Please mark this reply as a solution once the post is added to the PowerShell Forum.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.