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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
TCavins
Helper V
Helper V

Powershell Get-PowerBIDatasource - Name is blank

I'm using the following Powershell script to output a file that includes Workspace, dataset and datasource info. The Datasource name is always coming back empty. How can I loop through and get the info I want?

Install-Module -Name MicrosoftPowerBIMgmt -Scope CurrentUser

Login-PowerBI

$Workspace = Get-PowerBIWorkspace –All

$DataSets =

   ForEach ($workspace in $Workspace)

    {
Write-Host "Workspace: "
    Write-Host $workspace.Name
    

    ForEach ($dataset in (Get-PowerBIDataset -WorkspaceId $workspace.Id))

        {
		ForEach ($ds in (Get-PowerBIDatasource -DatasetId $dataset.Id -Scope Organization))
			{
        			[pscustomobject]@{

            			WorkspaceName = $Workspace.Name

            			WorkspaceID = $workspace.Id

            			DatasetName = $dataset.Name

            			DatasetID = $dataset.Id

					DatasourceName = $ds.Name
				}

            	}

        }

    }

   $Dir = "C:\pbi_test.csv"

   $DataSets | Export-Csv $Dir -NoTypeInformation -Encoding UTF8

   Write-Host "File created in " $Dir

   Disconnect-PowerBIServiceAccount
3 REPLIES 3
momo_man
Frequent Visitor

did you ever solve it. I am actually having the same issue

Anonymous
Not applicable

Hi @TCavins ,

 

As far as I know, Datasource Name should be in -Name part. It should look like-Name DatasoureName.

 

Get-PowerBIDatasource
   -Dataset <Dataset>
   [-WorkspaceId <Guid>]
   -Name <String>
   [-Scope <PowerBIUserScope>]
   [<CommonParameters>]

 

For reference: Get-PowerBIDatasource

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@Anonymous 


Thanks. I'm trying to return the dataset name or the source name of the dataset. From my understanding, the -Name is used for when you know the name and want to return records with a datasource of that name.

 

I don't know the names and we are trying to programmatically return all reports with their datasets/sources that are used in them so we can analyze it from there.

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

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 community update carousel

Fabric Community Update - June 2025

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