Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
daive
Regular Visitor

Scripting a refresh schedule

Hi all,

 

I am busy writing a process to import workspaces & reports into a new tenant. I am now on the refresh schedule and wanting to script it as all reports have different schedules.

 

I am following this article: https://martinschoombee.com/2020/10/27/automating-power-bi-deployments-update-refresh-schedule/

 

For now I am testing with one workspace and report but will eventually incorporate a csv and a loop

 

This is the actual script:

#API url for the refresh schedule
$ApiUrl = "groups/" + $WorkspaceObject.Id + "/datasets/" + $PbiReportObject.DatasetId + "/refreshSchedule" 

$ApiRequestBody = @"
    {
        "value": {
            "days": [
                "Sunday",
                "Monday",
                "Tuesday",
                "Wednesday",
                "Thursday",
                "Friday",
                "Saturday"
            ],
            "times": [
                "$RefreshTime"
            ],
            "notifyOption": "MailOnFailure", 
            "localTimeZoneId": "$Timezone", 
            "enabled": true
        }
    }
"@ 


#Update refresh schedule
Invoke-PowerBIRestMethod -Url $ApiUrl -Method Patch -Body ("$ApiRequestBody")

Write-Output "Data refresh schedule for report ""$ReportName"" updated successfully..."

 

Now i am geting this error

 

VERBOSE: Request Uri:
https://api.powerbi.com/v1.0/myorg/groups/796cceb9-aaa9-441e-900e-223b3z2e5719/datasets/86b9b214-c0f5-4682-9256-4462dba
4e370/refreshSchedule
VERBOSE: Status Code: Forbidden (403)
Invoke-PowerBIRestMethod : Encountered errors when invoking the command: {
  "code": "InvalidRequest",
  "message": "This operation is only supported for the dataset owner"

 

My user account and the service principle are both admins for the workspace. I have read that I may need to set the service principle as the dataset owner - is that necessary and what will be the consequence of doing that?

 

Thanks,
David

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

Yes, it is necessary, and yes, a semantic model "take over"  will result in ALL credentials being nuked and having to be re-provided.

View solution in original post

2 REPLIES 2
lbendlin
Super User
Super User

Yes, it is necessary, and yes, a semantic model "take over"  will result in ALL credentials being nuked and having to be re-provided.

Thanks @lbendlin ,

 

Credentials will need to be entered in any case as i am importing workspaces & reports into a new tenant.

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.