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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
jmillar
Helper I
Helper I

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 9
YMadden
Frequent 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

 

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

GilbertQ
Super User
Super User

Hi 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





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!







Power BI Blog

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

The way to do it manually is to go into each dataset, then click on Gateway Connection, it will show you which gateway it is using.




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!







Power BI Blog

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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

Top Solution Authors
Top Kudoed Authors