Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Powershell script to add and process a new SSAS Tabular partition
# Load Assembly
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.AnalysisServices") >$NULL
# Connect to Tabular SSAS
$srv = New-Object Microsoft.AnalysisServices.Server
$srv.connect("localhost\TABULAR")
# Point to a specific Database
$db = $srv.Databases.FindByName("DatabaseName");
# Store the Data Source View (*MUST* be Sandbox)
$dsv = $db.DataSourceViews.FindByName("Sandbox");
# Select a specific Model
$c = $db.Cubes.FindByName("ModelName");
# Select a specific Table
$mg = $c.MeasureGroups.FindByName("TableName");
# Add new partition and process it
$p = $mg.Partitions.Add("NewPartitionName");
$p.Source = New-Object Microsoft.AnalysisServices.QueryBinding($dsv.DataSourceID, "SELECT * FROM [Table] WHERE [PartitionColumn] = 1234");
$p.StorageMode = 'InMemory'
$p.Update('ExpandFull')
$p.Process('ProcessFull')
$srv.Disconnect()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.