cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mkjit256
Regular Visitor

Do i need to be a in a workspace to get dataset refresh through Invoke-PowerBIRest?

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

 

1 ACCEPTED 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

View solution in original post

4 REPLIES 4
mkjit256
Regular Visitor

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. 

mkjit256_0-1674266558737.png

and here is what i am getting as output: 

mkjit256_2-1674266766509.png

 

 

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

Daryl-Lynch-Bzy
Super User
Super User

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.

Helpful resources

Announcements
Carousel_PBI_Wave1

2023 Release Wave 1 Plans

Power BI release plans for 2023 release wave 1 describes all new features releasing from April 2023 through September 2023.

Power BI Summit Carousel 2

Global Power BI Training

Make sure you register today for the Power BI Summit 2023. Don't miss all of the great sessions and speakers!

BizApps LATAM 2023

Business Application LATAM Summit 2023

Join the biggest FREE Business Applications Event in LATAM this February.

Power Platform Bootcamp

Global Power Platform Bootcamp

In this bootcamp we will deep-dive into Microsoft’s Power Platform stack with hands-on sessions and labs, delivered to you by experts and community leaders.