Reply
Member
Posts: 77
Registered: ‎06-09-2016
Accepted Solution

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

Accepted Solutions
Community Support Team
Posts: 7,295
Registered: ‎05-02-2017

Re: PowerShell get-gateways always returns blank value

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


All Replies
Community Support Team
Posts: 7,295
Registered: ‎05-02-2017

Re: PowerShell get-gateways always returns blank value

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.
Member
Posts: 77
Registered: ‎06-09-2016

Re: PowerShell get-gateways always returns blank value

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

Community Support Team
Posts: 7,295
Registered: ‎05-02-2017

Re: PowerShell get-gateways always returns blank value

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.
Highlighted
Member
Posts: 77
Registered: ‎06-09-2016

Re: PowerShell get-gateways always returns blank value

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

Community Support Team
Posts: 7,295
Registered: ‎05-02-2017

Re: PowerShell get-gateways always returns blank value

[ Edited ]

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.
Member
Posts: 77
Registered: ‎06-09-2016

Re: PowerShell get-gateways always returns blank value

[ Edited ]

@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.

Member
Posts: 77
Registered: ‎06-09-2016

Re: PowerShell get-gateways always returns blank value

[ Edited ]

@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

Community Support Team
Posts: 7,295
Registered: ‎05-02-2017

Re: PowerShell get-gateways always returns blank value

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.
Member
Posts: 77
Registered: ‎06-09-2016

Re: PowerShell get-gateways always returns blank value

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