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
SamTrexler
Helper IV
Helper IV

PowerShell get-gateways always returns blank value

I am using PowerShell to retrieve information on dashboards, tiles, reports, datasets, dataset refreshes, etc. - using both the cmdlets and Invoke-PowerBIRestMethod. All is well, I am able to retrieve all of the information, send it to text files and insert it into SQL Server - except for directly retrieving gateways and the datasources in each gateway. I am able to use "/datasets/$DatasetId/Default.DiscoverGateways" to get the information on datasources and gateways in a given workspace. This gives me the datasourceId, gatewayId and all of the information about those objects. However, the datasource information and the gateway information is the same on every dataset. I would rather just retrieve the gateway itself, and the datasources in each gateway. But when I use "/gateways" or "/gateways/$GatewayId/datasources", all I get back is an empty "value". I have seen other posts in this forum indicating they also had this behavior (in the discussion of automating a task), but there was no reply or solution to that message in thread. Can anyone show me how to get the "/gateways" method to work? Thanks in advance, Sam
1 ACCEPTED SOLUTION

Hi Sam,

 

Since there isn't a REST API of gateways for Admin, I think you have gotten the expected result. 

 

Best Regards,

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

12 REPLIES 12
Anonymous
Not applicable

Hi All,

 

I faced with same issue. But I not clearly understand what is Power.BI.Global.Admin.

In my case I use service principal. But I could not find method to add SP to gateway admin list. 

Could you please suggest how can I use service principal for that? 

Thanks

v-jiascu-msft
Employee
Employee

Hi @SamTrexler,

 

What information would you like? Is it the information in power-bi/gateways/getdatasources? If so, you can use invoke-powerbirestmethod with the REST API.

 

 

Best Regards,
Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-jiascu-msft, thanks for the reply.

 

Yes, I want the data from the link you specified - as well as the information from its parent, the gateways.

 

I am using Invoke-PowerBIRestMethod successfully to retrieve workspaces, dashboards, dashboard tiles, reports, datasets, dataset gateways, dataset datasources and dataset refreshes. All of these invocations work correctly and return the data on my objects.

 

However, when I use "Invoke-PowerBIRestMethod -Url 'gateways' -Method Get" it returns an empty value - there are no gateways returned. So of course, that doesn't give me any gatewayids to use to get the datasources.

 

Funny thing is, when I use Invoke-PowerBIRestMethod where the Url contains "datasets/<datasetid>/gateways" I get the gateway each dataset connects to, and when I specify "datasets/<datasetid>/datasources" I get the datasource for each dataset.

 

But in this workspace those give me the same gateway on every dataset, and the same datasource on every dataset. What I want is a simple list of distinct gateways and distinct datasources, but those commands don't return anything.

 

By the way I am logging in as the Power BI Global Admin for the tenant, so all data should be available to me, correct?

 

Thanks,

Sam

Hi Sam,

 

Since you have known the APIs and the PowerShell tool very well, I would suggest you check your account permission. Even the Global Admin can't access everything. You can log in to the PBI Service to see what you can see. Please refer to the snapshot below. It's easy and clear. 

Power-Shell-get-gateways-always-returns-blank-value

 

Best Regards,
Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-jiascu-msft,

 

I did as you suggested and ran very simple commands in a new Windows Powershell session. Here are the results. Apparently I can't get the gateways directly? Is there a permisiion I need, or something?  Thanks,

 

GetGateways-Screenshot.jpgGetDatasetGateways.jpg

Hi @SamTrexler,

 

The cause isn't the permission. You definitely have the permission to get your gateways. I tried the same as yours and I got the expected result. 

Can you check if you have any gateways installed? Please refer to the snapshot below.

Power-Shell-get-gateways-always-returns-blank-value2

 

Best Regards,
Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-jiascu-msft, thanks for the reply. It seems like you may be getting me closer. But I'm still not successful.

 

Here is the list of gateways when I connect to Power BI. and a second screenshot showing the gateway in use in the workspace I'm concerned with.GatewayUsedInRITesting 2019-01-14 161603.jpg

 

Gateway List 2019-01-14 161459.jpg

As I showed in my post on 1/11, when I specify the workspace Id and use "Default.DiscoverGateways, I can retrieve this gateway. But when I simply specify "gateways" as the Url, I get nothing.

 

By the way, I am the account that owns all of the gateways. But when I am running the powershell script I connect to Power BI as the Power BI global administrator in our tenant.

 

Why does it work when I "Discover" the gateways for a particular workspace, but not when I ask for the gateways?

 

Thanks again for your help.

@v-jiascu-msft I think I have it solved. Tell me if this makes sense.

 

I tested connecting as "Power.BI.Global.Admin" and the "gateways" url returns nothing.

 

I tested connecting as myself and I get the list of five gateways.

 

I went to Manage Gateways and added "Power.BI.Global.Admin" as an Administrator of the one gateway I'm interested in right now.

 

I re-tested as "Power.BI.Global.Admin" and now I get the list of all five gateways.

 

I also get the list of datasources when I specify -url "gateways\<gatewayid>\datasources".

 

When I get the list of gateways, I get all five gateways - even though I only added this user as an administrator of one of the gateways.

 

Is this the right way to go about it - do I need to make the global admin account an administrator on at least one gateway?

 

And is it expected behavior that this would give me all five of the gateways?

 

Thanks,

 

Sam

Hi Sam,

 

I'm glad you can make it work now. 

I can't reproduce the same as your descriptions. My result always shows the gateways that the account has or the account has the administrator permission. If you can provide more details, I will test again.

 

 

Best Regards,

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

HI @v-jiascu-msft

 

It seems to be working correctly now. I don't know why I got all five gateways the first time, pobably a coding error on my part.

 

At this point I have it pretty well debugged. And I get every gateway in the tenant which has my connection account as an administrator.

 

Is that expected behavior?

 

Thanks,

 

Sam

Hi Sam,

 

Since there isn't a REST API of gateways for Admin, I think you have gotten the expected result. 

 

Best Regards,

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks, @v-jiascu-msft. You have been very helpful.

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.