Get certified for free when you join Fabric Data Days 2026 and dive into Fabric, Power BI, SQL, AI, and other essential data skills.
Join nowTry your skills in the Power BI Dataviz World Championship! Round one ends June 26. Join now
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
Solved! Go to 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:
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
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:
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 0For SSIS:
Update the PBIXPath and LogFile parameters in the script as per your env.
Add the script task to the SSIS Control Flow and configure accordingly.
Hope it helps!
Best,
Harshit
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.
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:
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:
Microsoft Power BI Cmdlets for Windows PowerShell and PowerShell Core
Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.
Check out the May 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 24 | |
| 22 | |
| 21 | |
| 20 | |
| 14 |
| User | Count |
|---|---|
| 59 | |
| 52 | |
| 41 | |
| 33 | |
| 32 |