Forum Discussion

SamTrexler's avatar
SamTrexler
Icon for Helper IV rankHelper IV
7 years ago
Solved

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

12 Replies

    • SamTrexler's avatar
      SamTrexler
      Icon for Helper IV rankHelper IV

      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

      • v-jiascu-msft's avatar
        v-jiascu-msft
        Icon for Microsoft Employee rankMicrosoft Employee

        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

  • Anonymous's avatar
    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