Forum Discussion
PowerShell script to retrieve list data sources used in Power BI dataset
- 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!
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
Result
Best Regards,
Zhu
Community Support Team
If 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!