Skip to content

Instantly share code, notes, and snippets.

@dgosbell
Created June 16, 2023 00:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dgosbell/1ab4ae3745db384e23db8ccd36f09ee2 to your computer and use it in GitHub Desktop.
Save dgosbell/1ab4ae3745db384e23db8ccd36f09ee2 to your computer and use it in GitHub Desktop.
## This script will apply an incremental refresh policy to generate
## empty partitions for that policy using a Service Principal via the XMLA endpoint
$workspace = "XMLA%20Test"
$databaseName = "Adv Works Inc Refresh Base"
$tableName = "Internet Sales"
$clientID = "<Your SPN Client ID>"
$tenantID = "<Your TenantID>"
$clientSecret = "<Your SPN Secret>"
##
$connStr = "Data Source=powerbi://api.powerbi.com/v1.0/myorg/$workspace;User ID=app:$($clientID)@$($tenantID);Password=$clientSecret"
## Load AMO - via loading the SqlServer module
import-module SqlServer
## connect to the XMLA endpoint
$server = new-object Microsoft.AnalysisServices.Tabular.Server
$server.Connect($connStr)
$db = $server.Databases.FindByName($databaseName)
$table = $db.Model.Tables[$tableName]
"Initial Partition count: $($table.Partitions.Count)"
$table.ApplyRefreshPolicy($false, 1)
"Final Partition count: $($table.Partitions.Count)"
$server.Disconnect()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment