Forum Discussion

heylumi's avatar
heylumi
Regular Visitor
4 years ago
Solved

Powershell Rest Api - Taking over dataset and updating datasource

Hey guys   Just wondering if anyone has any idea why the very last line in the below powershell script would fail assuming that that one is able to get a valid GatewayId and datasourceId? I know th...
  • heylumi's avatar
    heylumi
    4 years ago

    Hey Anonymous 

     

    Thank you very much for your input. I was largely able to make rest api calls using the Invoke-PowerBIRestMethod so this in itself wasn't the problem. I think my issue mostly related to a lack of understanding on how to programatically make use of an existing gateway to do the refresh via the service principal which has a couple of gotchas that were not immediately obvious (in my case at least).

     

    It turns out that the service principal that was added to a 365 group (group was granted access to the datasource via the PowerShell UI) didn't actually have access to the datasource in the gateway even though the group was added and appears in the list of users. I needed to add the service principal account directly to get it working as expected using the Datagateway commandlets via Powershell 7 (this was the gotcha for me)

     

    There is another video by Guy In A Cube which explains the process rather well if anyone is interested in getting this working. See here: PowerShell Service Principal Refresh