powerbiwindows-task-scheduler

Is it possible to schedule refresh in Power BI with Windows Task Schedule?


My Power BI report's Scheduled refresh doesn't work. So I'm trying to understand if it is possible to create a task in the Windows Task Scheduler, that opens the Power BI and refreshes the report automatically at a given time. Does anyone have experience doing this?


Solution

  • If the scheduled refresh doesn't work (you didn't said what this actually means), then the manual will not work either. But if you want to try, a PowerShell script to call the REST API is an option for refreshing a dataset. It uses Microsoft Power BI Cmdlets. Fill in the workspace and report IDs, along with your credentials, and run the script bellow:

    Import-Module MicrosoftPowerBIMgmt
    Import-Module MicrosoftPowerBIMgmt.Profile
    
    $password = "xxxxxxxxxxxxxxxxxxxxx" | ConvertTo-SecureString -asPlainText -Force
    $username = "xxxxxxxx@xxxxxxxx.com" 
    $credential = New-Object System.Management.Automation.PSCredential($username, $password)
    
    Connect-PowerBIServiceAccount -Credential $credential
    
    Invoke-PowerBIRestMethod -Url 'groups/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/datasets/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/refreshes' -Method Post
    
    Disconnect-PowerBIServiceAccount 
    

    You can run it with Windows Task Scheduler too. Please note, that with Power BI Free you are limited to 1 refresh per 24h for a dataset or 8 times with Power BI Pro account.

    But of course, it will be better to understand why your scheduled refreshes "doesn't work" first.