Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code FABINSIDER for a $400 discount.
Register nowThe Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.
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
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
Thank you so much for posting this. Much appreciated.
Awesome!
This is very good, Can we get dataset refresh schdlue information from these scripts?
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
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
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
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the February 2025 Power BI update to learn about new features.
If you love stickers, then you will definitely want to check out our Community Sticker Challenge!
User | Count |
---|---|
41 | |
27 | |
23 | |
22 | |
21 |
User | Count |
---|---|
53 | |
40 | |
22 | |
22 | |
21 |