Reputation: 122
I would like to know if I can use PowerShell to refresh data in Power BI? I am not using the publish option, but am instead using an Excel document from a share drive.
Upvotes: 0
Views: 8338
Reputation: 122
C:\Reports\Templates\Sensor_Exporter\Master8.pbix
Start-Sleep -s 20 $wshell = New-Object -ComObject Wscript.Shell
[void] [System.Reflection.Assembly]::LoadWithPartialName("'Microsoft.VisualBasic");
[Microsoft.VisualBasic.Interaction]::AppActivate("Master8 - Power BI Desktop");
Start-Sleep -s 5
$wshell.SendKeys("%H R");
Start-Sleep -s 2
$wshell.SendKeys("r")
Upvotes: 2
Reputation: 13460
I am not using the publish option, but am instead using an Excel document from a share drive.
Due to the above quote, I will assume that you are asking is it possible to refresh a pbix file, which you view in Power BI Desktop, and not how to refresh a report published to Power BI online.
No, Power BI Desktop can't be automated with PowerShell. You have to open the report in Power BI Desktop and click Refresh
command in the ribbon:
If you want to use PowerShell to refresh this report, you must publish it to Power BI Online and use Refresh Dataset or Refresh Dataset In Group from Power BI REST API to refresh the dataset. You can do this by installing Microsoft Power BI Cmdlets:
Install-Module -Name MicrosoftPowerBIMgmt -Scope CurrentUser
And then login into Power BI and call the method you want, e.g.:
Login-PowerBI
Invoke-PowerBIRestMethod -Url 'groups/gggggggg-gggg-gggg-gggg-gggggggggggg/datasets/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/refreshes' -Method Post
You must provide actual group ID an dataset ID in the url above.
Upvotes: 1