Forum Discussion
PowerShell script example on how to run full refresh of incremental dataset?
- 5 years ago
Found out how to pull it off.
You create a .json file with this information:
{ "refresh": { "type": "full", "applyRefreshPolicy": false, "objects": [ { "database": "Your Dataset Name" } ] } }Then you create an Powershell script-file:
#Set Credentials $userName = "[email protected]" $password = ConvertTo-SecureString -String "YourPassword" -AsPlainText -Force $Credential = New-Object -TypeName "System.Management.Automation.PSCredential" -ArgumentList $userName, $password #Execute refresh $InputFileRefresh ="D:\MyJsonFile.json" invoke-ascmd -Server "powerbi://api.powerbi.com/v1.0/myorg/Your Workspace Name" -InputFile $InputFileRefresh -Credential $CredentialThat runs a full refresh of the dataset (but you won't see it running in the Power BI service and the Last Refresh Date in the PBI service will not be updated, just the data in the dataset).
Found out how to pull it off.
You create a .json file with this information:
{
"refresh": {
"type": "full",
"applyRefreshPolicy": false,
"objects": [
{
"database": "Your Dataset Name"
}
]
}
}Then you create an Powershell script-file:
#Set Credentials
$userName = "[email protected]"
$password = ConvertTo-SecureString -String "YourPassword" -AsPlainText -Force
$Credential = New-Object -TypeName "System.Management.Automation.PSCredential" -ArgumentList $userName, $password
#Execute refresh
$InputFileRefresh ="D:\MyJsonFile.json"
invoke-ascmd -Server "powerbi://api.powerbi.com/v1.0/myorg/Your Workspace Name" -InputFile $InputFileRefresh -Credential $CredentialThat runs a full refresh of the dataset (but you won't see it running in the Power BI service and the Last Refresh Date in the PBI service will not be updated, just the data in the dataset).
- Clement_lsc4 years agoFrequent Visitor
Hello Chris,
Thank you for the script.
Unfortunately I have an issue trying to execute the full refresh using "invoke-ascm". I don't understand how to trigger the json created just before in the ascm command.Thank you in advance. 😀
- ChrisRenlund4 years agoAdvocate I
Hi Clement_lsc ,
It seems as you are adding the .json-content directly to a variable in the Powershell script?
The way I did it was that I created a separate .json-file containing the .json-commands, then I created a variable in the Powershell-script that pointed out the .json-file:$InputFileRefresh ="D:\MyJsonFile.json"And then I used that variable in the invoke-ascmd-command (the -InputFile tag):
invoke-ascmd -Server "powerbi://api.powerbi.com/v1.0/myorg/Your Workspace Name" -InputFile $InputFileRefresh -Credential $CredentialMaybe there is a better way, but this is what made it work for me!
- Clement_lsc4 years agoFrequent Visitor
Ok thank you for your answer. 😀
What module did you downloaded in order to run "Invoke-ascm" ?
I have an error message " invoke-ascmd' is not recognized as the name of a cmdlet" even with the Sqlserver and MicrosoftPowerBIMgmt.Profile modules.
Sorry i'm a beginner...Thank you for your time.
- Anonymous3 years agoNot applicable
"but you won't see it running in the Power BI service and the Last Refresh Date in the PBI service will not be updated, just the data in the dataset" it is really? If I use Powershell single table full brush, there is no response, and the html code appears, is it the meaning of the refresh success?
- ChrisRenlund3 years agoAdvocate I
Hi Jackson,
Is the script not working for you? I can verify that my data is fully refreshed by checking the partitions through Microsoft SQL Server Management studio and all partitions get processed when i run the script:Nowadays you can also see a successful refresh in the refresh history in the Power BI Service and it states that it is initiaded via an xmla-endpoint:
If you're having issues with the script - check that you have the powershell modules referred to in my discussion with Clement_Isc in this thread and that you have enabled read-write for XMLA-endpoints in the Admin Portal.
- afm_bcn2 years agoNew Member
Hi Chris:
This sounds fine when refreshing a PowerBI dataset.
But do you know how to do the same for a PowerBI dataflow?
Even though, I've properly copied the script and changing the name of the dataflow instead of "Your dataset name", it doesn't work at all.
Do you have any idea?- ChrisRenlund2 years agoAdvocate I
Hi, afm_bcn ,
Sorry, haven't tried it for a dataflow. But Dataflows doesn't show up as a database when you connect to a workspace with SQL Server management studio either, so I guess it's not the same type of workspace object.
I do know that we're able to refersh dataflows with API-calls, but don't have any with incremental refresh set up, so haven't looked into that.