Forum Discussion
How can I determine which datasets are using a gateway connection?
We're moving some servers around, and I'd like to know if there's a way to determine which datasets are using a specific gateway connection and/or if there's a way to change the server for a gateway connection with dropping and recreating.
Thanks,
Jason
9 Replies
- YMaddenFrequent Visitor
I realize this thread is old, but we just finished a powershell script that builds an Excel workbook where we can link the gateway connections to dataset datasources. We still have to do a vlookup between the worksheets to find what is being used. It's not picking up connections for Paginated Reports, either.
You'll need to install the PowerBI and Excel modules first.
Install-Module -Name MicrosoftPowerBIMgmt
Install-Module -Name ImportExcel
Then run this. It might kick out some errors if you don't have access to a given workspace.
$scope = "Organization" #Individual $filter = "(type eq 'Workspace') and (state eq 'Active')" Connect-PowerBIServiceAccount Get-PowerBIWorkspace -All -scope $scope -Filter $filter | Select-Object -Property "Id","Name","IsReadOnly","IsOnDedicatedCapacity","CapacityId","Description","Type","State","IsOrphaned" | Export-Excel -Path C:\Temp\PowerBI\PowerBI_WorkspaceDetails.xlsx -WorksheetName "Workspaces" -AutoSize Get-PowerBIWorkspace -Scope $scope -All -Filter $filter | Foreach { $wsId = $_.Id; $wsName=$_.Name; Get-PowerBIReport -WorkspaceId $wsId -Scope $scope | Select-Object -Property ID, Name, WebUrl, DatasetId | Foreach { [PSCustoMObject]@{ 'WSID' = $wsId; 'WSName' = $wsName; 'reportId' = $_.ID; 'reportName' = $_.Name; 'reportDataset' = $_.DatasetId; 'reportURL' = $_.WebUrl } } } | Export-Excel -Path C:\Temp\PowerBI\PowerBI_WorkspaceDetails.xlsx -WorksheetName "Reports" -AutoSize Get-PowerBIWorkspace -Scope $scope -All -Filter $filter | Foreach { $wsId = $_.Id; $wsName=$_.Name; Get-PowerBIDataset -Scope $scope -WorkspaceId $wsId | Foreach { $dsID = $_.Id; $dsName = $_.Name; Get-PowerBIDatasource -DatasetId $dsID -Scope $scope | Foreach { [PSCustoMObject]@{ 'WSID' = $wsId; 'WSName' = $wsName; 'DSID' = $dsID; 'DSName' = $dsName; 'SrcId' = $_.DatasourceId; 'SrcName' = $_.Name; 'SrcType' = $_.DatasourceType; 'SrcConnectString' = $_.ConnectionString; 'SrcDtlServer' = $_.ConnectionDetails.server; 'SrcDtlDB' = $_.ConnectionDetails.database } } } } | Export-Excel -Path C:\Temp\PowerBI\PowerBI_WorkspaceDetails.xlsx -WorksheetName "Datasources" -AutoSize # Get gateways $gateways = Invoke-PowerBIRestMethod -Url 'gateways' -Method Get | ConvertFrom-Json $gateways.value | ForEach { $gwID = $_.id $datasources = Invoke-PowerBIRestMethod -Url "gateways/$($gwID)/datasources" -Method Get | ConvertFrom-Json $datasources.value | ForEach { $connDetails = $_.connectionDetails | ConvertFrom-Json [PSCustoMObject]@{ 'datasourceId' = $_.id; 'datasourceName' = $_.datasourceName; 'datasourceType' = $_.datasourceType; 'datasourceDtlServer' = $connDetails.server; 'datasourceDtlDB' = $connDetails.database; 'datasourceDtlPath' = $connDetails.path; 'datasourceDtlExtType' = $connDetails.extensionDataSourceKind; 'datasourceDtlExtPath' = $connDetails.extensionDataSourcePath; 'datasourceDtlODBCConnString' = $connDetails.connectionString; 'datasourceDtlURL' = $connDetails.url } } } | Export-Excel -Path C:\Temp\PowerBI\PowerBI_WorkspaceDetails.xlsx -WorksheetName "Gateway Datasources" -AutoSize- btiitkRegular Visitor
This is very good, Can we get dataset refresh schdlue information from these scripts?
- YMaddenFrequent Visitor
The Refresh Schedule is available through the REST API. You could call it inline with the scripts above.
https://learn.microsoft.com/en-us/rest/api/power-bi/datasets/get-refresh-schedule
- mkarimRegular Visitor
Awesome!
- blopez11Super User
Thank you so much for posting this. Much appreciated.
- GilbertQSuper UserHi there
THis API will tell you which data sources are for which datasets. It also contains the GatewayID which will relate to your Gateway.
https://docs.microsoft.com/en-us/rest/api/power-bi/admin/datasets_getdatasourcesasadmin
This will give you the Gateway details:
https://docs.microsoft.com/en-us/rest/api/power-bi/gateways/getgateways
This one might be the one to update the data sources
https://docs.microsoft.com/en-us/rest/api/power-bi/datasets/updatedatasourcesingroup- jmillarHelper I
That's great info, thanks! -- I haven't played much with the API yet. I'm assuming I need to register an app before I have access to the REST APIs? Is that approach appropriate even for internal ad-hoc utilities, etc., that aren't an app in the traditional sense (e.g. it'd be an internal "app" meant only for administrator and to query items that the above that can't readily be seen via the Service UI).
J
- cperuskiAdvocate II
Were you able to successfully get the gateway information? And if so, what were the steps you followed? I'm totally out of my element with APIs. Thanks