Forum Discussion
Powershell Rest Api - Taking over dataset and updating datasource
- 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
Hi heylumi
Use Invoke-Power
For example:
Use Rest API to get Groups by Powershell.
...
Invoke-PowerBIRestMethod -Url 'Groups/GroupID...' -Method Get
You may refer to this video for more details about how to call Power BI Rest API by Powershell.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- heylumi4 years agoRegular Visitor
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