Forum Discussion
PowerShell script to retrieve list data sources used in Power BI dataset
Hello All,
Is there a way to find out how many PowerBI reports are connected to which data source? Using PowerShell or REST api?
Thanks In advance.
- Anonymous2 years ago
Hi Ynr0225 ,
Thank for your reply, blopez11 . I will add one more point here.
I use the API to meet your requirements:
1.Please open the workspace and get you workspaceID.
2.Click F12 and get the token.
Or you can get token by following the steps in the link https://learn.microsoft.com/en-us/rest/api/power-bi/datasets/get-datasources :
3.Write a new query and then you can see the final result:
The M code is attached:
let workspaceID = "__your workspaceID__", token = "Bearer ___token___", Url = https://api.powerbi.com, GetReportID = Table.FromRecords(Json.Document(Web.Contents( Url, [ Headers = [ Authorization = token ], RelativePath ="/v1.0/myorg/groups/"&workspaceID&"/reports" ] ) )[value] )[[id],[name],[datasetId]], fx = (datasetId as text) as table => let url = Text.Format("/v1.0/myorg/datasets/#{0}/datasources", {datasetId}), result = Table.FromRecords( Json.Document( Web.Contents( Url, [ Headers = [ Authorization = token ], RelativePath = url ] ) )[value] ) in result, Result = Table.ExpandTableColumn( Table.AddColumn( GetReportID, "dataSourceInfo", each fx([datasetId]) ), "dataSourceInfo", {"datasourceType", "connectionDetails"} ) in ResultBest Regards,
Zhu
Community Support TeamIf there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
2 Replies
- blopez11Super User
Yes, most things are possible, but some require more effort than others. You might find the below blog interesting, and they also include link to source code.
https://insightsquest.com/2019/06/19/power-bi-artifact-to-workspace-relationships/
- AnonymousNot applicable
Hi Ynr0225 ,
Thank for your reply, blopez11 . I will add one more point here.
I use the API to meet your requirements:
1.Please open the workspace and get you workspaceID.
2.Click F12 and get the token.
Or you can get token by following the steps in the link https://learn.microsoft.com/en-us/rest/api/power-bi/datasets/get-datasources :
3.Write a new query and then you can see the final result:
The M code is attached:
let workspaceID = "__your workspaceID__", token = "Bearer ___token___", Url = https://api.powerbi.com, GetReportID = Table.FromRecords(Json.Document(Web.Contents( Url, [ Headers = [ Authorization = token ], RelativePath ="/v1.0/myorg/groups/"&workspaceID&"/reports" ] ) )[value] )[[id],[name],[datasetId]], fx = (datasetId as text) as table => let url = Text.Format("/v1.0/myorg/datasets/#{0}/datasources", {datasetId}), result = Table.FromRecords( Json.Document( Web.Contents( Url, [ Headers = [ Authorization = token ], RelativePath = url ] ) )[value] ) in result, Result = Table.ExpandTableColumn( Table.AddColumn( GetReportID, "dataSourceInfo", each fx([datasetId]) ), "dataSourceInfo", {"datasourceType", "connectionDetails"} ) in ResultBest Regards,
Zhu
Community Support TeamIf there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!