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

Try your skills in the Power BI Dataviz World Championship! Round one ends June 26. Join now

Reply
mj2024
Helper II
Helper II

Automate the refresh of a Power BI Dashboard

Hi everyone

 

I am using Power BI Desktop Version: 2.138.1452.0 32-bit (November, 2024).  My dashboard gets data from SQL Server tables.  I use SSIS to automate ETL.  I would like to create a script to automate the refresh of my dashboard.  I am thinking that maybe PowerShell might be a solution but I have never done this before.  How can I tell SSIS to automate the refresh of the dashboard?  If PowerShell is an option then can you please provide the script?

 

Thank you

1 ACCEPTED SOLUTION

Hello @mj2024,

Power BI Desktop is mainly for creating reports and working with data. It doesn’t support automated or background refresh
In a local setup (PBIX + SQL Server on your machine), there is no supported PowerShell or SSIS method to trigger an automatic refresh of the report in Desktop.

Refresh automation is only supported when the report is published to Power BI Service, where you can use:
Scheduled refresh, or
REST API / PowerShell to trigger dataset refresh after your SSIS ETL completes
Docs:

Data refresh in Power BI 

View solution in original post

7 REPLIES 7
v-sshirivolu
Community Support
Community Support

Hi @mj2024 ,

I would also take a moment to thank @Olufemi7 , for actively participating in the community forum and for the solutions you’ve been sharing in the community forum. Your contributions make a real difference.

 

I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions

Hi @mj2024 ,

I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions

 

stoic-harsh
Solution Supplier
Solution Supplier

Hey @mj2024,

I would prefer the Power BI Service approach. You can simply publish, schedule refresh in browser, and point at local SQL Server using a Data Gateway, all in just a few clicks.

That said, a Powershell script also works like a charm. The script below performs the job as follows:

  1. Closes any open PowerBI instances.
  2. Waits for the report to open completely (increase the wait time if needed).
  3. Dismisses the startup splash screen.
  4. Triggers refresh using keyboard shortcuts (Alt, H, R, Down Arrow, Enter)
  5. Waits for the refresh (increase the wait time if it takes longer for you)
  6. Saves the changes.
  7. Closes the report.
  8. Logs all actions to the file specified in the script.
param(
    [string]$PBIXPath = "C:\Users\GuptaHarshit\Downloads\SampReport.pbix",
    [int]$LoadWaitSec = 240,
    [int]$RefreshWaitSec = 60,
    [string]$LogFile = "C:\Users\GuptaHarshit\Downloads\RefreshLog.txt"
)

function Write-Log {
    param([string]$Message)
    $timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
    $line = "$timestamp  $Message"
    Write-Host $line
    Add-Content -Path $LogFile -Value $line
}

Add-Type @"
using System;
using System.Runtime.InteropServices;
public class WinAPI {
    [DllImport("user32.dll")] public static extern bool SetForegroundWindow(IntPtr h);
    [DllImport("user32.dll")] public static extern bool ShowWindow(IntPtr h, int n);
}
"@

Add-Type -AssemblyName System.Windows.Forms

Write-Log "Checking for existing Power BI Desktop instances..."
$existing = Get-Process -Name "PBIDesktop" -ErrorAction SilentlyContinue
if ($existing) {
    Write-Log "Found existing instance - closing it first..."
    Stop-Process -Name "PBIDesktop" -Force
    Start-Sleep -Seconds 5
}

Write-Log "Launching Power BI Desktop with: $PBIXPath"
$pbiExe = "C:\Program Files\Microsoft Power BI Desktop\bin\PBIDesktop.exe"

if (-not (Test-Path $pbiExe)) {
    $pbiExe = "C:\Program Files (x86)\Microsoft Power BI Desktop\bin\PBIDesktop.exe"
}

if (-not (Test-Path $pbiExe)) {
    Write-Log "ERROR: Power BI Desktop executable not found."
    Exit 1
}

Start-Process -FilePath $pbiExe -ArgumentList $PBIXPath
Write-Log "Waiting $LoadWaitSec seconds for Power BI to fully load..."
Start-Sleep -Seconds $LoadWaitSec

$pbi = Get-Process -Name "PBIDesktop" -ErrorAction SilentlyContinue
if (-not $pbi) {
    Write-Log "ERROR: Power BI Desktop did not start."
    Exit 1
}

[WinAPI]::ShowWindow($pbi.MainWindowHandle, 9)
[WinAPI]::SetForegroundWindow($pbi.MainWindowHandle)
Start-Sleep -Seconds 3

# Dismiss the splash/sign-in popup by pressing Escape
Write-Log "Dismissing startup splash screen..."
[System.Windows.Forms.SendKeys]::SendWait("{ESC}")
Start-Sleep -Seconds 3

# Click the main Power BI window to make sure it has focus
[WinAPI]::SetForegroundWindow($pbi.MainWindowHandle)
Start-Sleep -Seconds 2

# Trigger refresh via ribbon: Alt, H, R, Down Arrow, Enter
Write-Log "Triggering refresh via ribbon..."
[System.Windows.Forms.SendKeys]::SendWait("%")
Start-Sleep -Seconds 2
[System.Windows.Forms.SendKeys]::SendWait("h")
Start-Sleep -Seconds 2
[System.Windows.Forms.SendKeys]::SendWait("r")
Start-Sleep -Seconds 2
[System.Windows.Forms.SendKeys]::SendWait("{DOWN}")
Start-Sleep -Seconds 1
[System.Windows.Forms.SendKeys]::SendWait("{ENTER}")

Write-Log "Waiting $RefreshWaitSec seconds for refresh to complete..."
Start-Sleep -Seconds $RefreshWaitSec

Write-Log "Saving the file (Ctrl+S)..."
[System.Windows.Forms.SendKeys]::SendWait("^s")
Start-Sleep -Seconds 10

Write-Log "Closing Power BI Desktop..."
Stop-Process -Name "PBIDesktop" -Force
Start-Sleep -Seconds 3

Write-Log "SUCCESS: Refresh complete."
Exit 0

For SSIS:

  1. Update the PBIXPath and LogFile parameters in the script as per your env.

  2. Add the script task to the SSIS Control Flow and configure accordingly.

Hope it helps!

Best,
Harshit

Kagiyama_yutaka
Advocate III
Advocate III

I think pbix can’t be refreshed from outside, so the usual pattern is publish it once to the Service, then let SSIS call a small PowerShell script that triggers the dataset refresh through the API. u just drop your token + datasetId into the script and it’ll run.

mj2024
Helper II
Helper II

Hi @Olufemi7 

Thank you for the reply.  

The Power BI is stored on my local machine.  I do not publish it anywhere.  The SQL Server is also stored on my machine.  Do you have a PowerShell script that will do the refresh?

Thank you

Hello @mj2024,

Power BI Desktop is mainly for creating reports and working with data. It doesn’t support automated or background refresh
In a local setup (PBIX + SQL Server on your machine), there is no supported PowerShell or SSIS method to trigger an automatic refresh of the report in Desktop.

Refresh automation is only supported when the report is published to Power BI Service, where you can use:
Scheduled refresh, or
REST API / PowerShell to trigger dataset refresh after your SSIS ETL completes
Docs:

Data refresh in Power BI 

Olufemi7
Solution Sage
Solution Sage

Hello @mj2024,

PowerShell is most appropriate for this situation.
Since you already use SSIS for ETL, a common approach is:
SSIS → Power BI dataset refresh
Usually the PBIX is published to Power BI Service, then SSIS calls a PowerShell script (via Execute Process Task) or the REST API to refresh the dataset after the ETL finishes.

If the SQL Server source is on-premises, you may also need an On-premises Data Gateway.
Docs:

Datasets - Refresh Dataset 

Microsoft Power BI Cmdlets for Windows PowerShell and PowerShell Core 

Helpful resources

Announcements
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

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

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.