Search code examples
powerbipowershell-5.0

How to update/edit refresh schedules using API?


We have 100's of reports that were falling behind in refresh schedule, and Microsoft confirmed with us that that is the way it works: refreshes are queued as FIFO, so the more refresh plans on the server, the more it will take time for reports to get their turn to refresh, regardless of the schedule expectation.

After discussions, we have decided to establish refresh schedule governance, so users wont be creating the schedules, we will. But there are hundreds of schedules in place (1 for each report) and it will take forever to update them manually one by one.

How can we update the schedules, to say perform a refresh at 10am or 2 pm daily?

i was able to drill down to the cacherefreshplan information but i am unsure how to "update it" with new values. On swagger, i am seeing PUT, but not sure if that is the right method...

    $refreshplan = Invoke-RestMethod -UseDefaultCredentials <# -Credential $creds #> -uri $($baseURI + "api/v2.0/PowerBIReports(path='" + "/Prototypes/report 1" + "')/CacheRefreshP
lans")

$refreshplan.value.ScheduleDescription

At 2:00 AM every day, starting 9/5/2019

$refreshplan.value.Schedule.Definition

StartDateTime             EndDate              EndDateSpecified Recurrence
-------------             -------              ---------------- ----------
2019-09-05T02:00:00-04:00 0001-01-01T00:00:00Z            False @{MinuteRecurrence=; DailyRecurrence=; WeeklyRecurrence=; MonthlyRecurrence=; MonthlyDOWRecurrence=}


$refreshplan.value.Schedule.Definition.StartDateTime

2019-09-05T02:00:00-04:00

Solution

  • You need to call Update Refresh Schedule In Group API and pass the new schedule, e.g.:

    {
      "value": {
        "days": [
          "Sunday",
          "Tuesday",
          "Friday",
          "Saturday"
        ],
        "times": [
          "07:00",
          "11:30",
          "16:00",
          "23:30"
        ],
        "localTimeZoneId": "UTC"
      }
    }
    

    To find the groups you can use Get Groups API and enumerate over datasets in a group using Get Datasets In Group API, or you can prepare a list for yourself, of course.