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).
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. ๐
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.
- ChrisRenlund4 years agoAdvocate I
And just to double cross everything - sometimes you refer to the command as "invoke-ascm", make sure you have "invoke-ascmd" in your powershell code?
- ChrisRenlund4 years agoAdvocate I
It seems as it is part of the SqlServer module (https://docs.microsoft.com/en-us/powershell/module/sqlserver/invoke-ascmd?view=sqlserver-ps)
These are the modules I have on the server where the script is running (you can get yours with the Get-InstalledModule command):Version Name Repository Description 3000.10... DataGateway PSGallery Data Gateway PowerShell cmdlets 3000.10... DataGateway.Profile PSGallery Data Gateway PowerShell - Profile credential management cmdlets for Data Gateway 1.12 Microsoft.ADAL.PowerShell PSGallery ADAL module for PowerShell 21.1.18230 SqlServer PSGallery This module allows SQL Server developers, administrators and business intelligence prof... - Clement_lsc4 years agoFrequent Visitor
Hello Chris,
I managed to fix my script. It works now !
I had some securities on my laptop that blocked the SQL SERVER module.
Moreover, I had to change a parameter in Power BI service to make it work (XMLA authorizations). If some of you encoutered the same issue, here is the solution :Pass it to read/write.
Thank you Chris, have a nice day.Clรฉment