Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more
Hello
I am using the code from this blog
Connect-PowerBIServiceAccount
$Workspaces = Get-PowerBIWorkspace -Scope Organization
foreach($workspace in $Workspaces)
{
$DataSets = Get-PowerBIDataset -WorkspaceId $workspace.Id | where {$_.isRefreshable -eq $true}
foreach($dataset in $DataSets)
{
$URI = "groups/" + $workspace.id + "/datasets/" + $dataset.id + "/refreshes"
$Results = Invoke-PowerBIRestMethod -Url $URI -Method Get
Write-Host $Results
}}
I am able to get all the workspaces and datasets in the organization, using Get-PowerBIworkspace and Get-PowerBIDataset in the Foreach loops.
However when i use
Invoke-PowerBIRestMethod -Url $URI -Method Get
, i am only getting the refresh date of Datasets that are found to workspaces where i was added as a member.
How can i get the refresh date of all datasets in my organization?
am i missing any permission for reading the datasets in organization using Invoke-PowerBIRestMEthod but not using Get-PowerBIDataset
Solved! Go to Solution.
@Daryl-Lynch-Bzy Thanks for your reply. It helped me finding this (which was exactly what i was looking for):
Admin - Get Refreshables - REST API (Power BI Power BI REST APIs) | Microsoft Learn
Thanks for your reply @Daryl-Lynch-Bzy Sorry for mis explaining, I am a power BI Adminstrator (I thought anyone that can get the Dataset with -scope organization, is a power bi Admin, and that is why id didn't mention it before).
I believe that you mean by "to run the Admin API calls", is to connect to powerbi-services using my admin activated account, right? If yes, then this is exactly what i am doing, but i am unable to get the refresh dates for dataset unless they are in the workspace that i was added in? any possible explanations.
and here is what i am getting as output:
Hi @mkjit256 - there is a difference between normal and admin API calls. If a Power BI Administrator runs the normal API calls they will only see results for the workspaces where they are members. Take the following examples:
Groups - Get Groups - REST API (Power BI Power BI REST APIs) | Microsoft Learn
GET https://api.powerbi.com/v1.0/myorg/groups
Admin - Groups GetGroupsAsAdmin - REST API (Power BI Power BI REST APIs) | Microsoft Learn
GET https://api.powerbi.com/v1.0/myorg/admin/groups?$top={$top}
The first require workspace access. The second allows admin to see the groups without actually providing access to the underlying data.
If you think about the following API call:
Datasets - Execute Queries - REST API (Power BI Power BI REST APIs) | Microsoft Learn
POST https://api.powerbi.com/v1.0/myorg/datasets/{datasetId}/executeQueries
The Power BI Administrator should have access to run unless they are granted access to use the Dataset.
@Daryl-Lynch-Bzy Thanks for your reply. It helped me finding this (which was exactly what i was looking for):
Admin - Get Refreshables - REST API (Power BI Power BI REST APIs) | Microsoft Learn
Hi @mkjit256 - Yes. You account would need to be Admin or Member of each Workspace to run the type of API. The alternative is to run the Admin API calls if you are Power BI Administrator or to use a Service Principal.
User | Count |
---|---|
14 | |
10 | |
9 | |
8 | |
5 |