Skip to content

Instantly share code, notes, and snippets.

@yorek
Last active April 26, 2022 01:42
Show Gist options
  • Select an option

  • Save yorek/bf87857e0074fccec28c to your computer and use it in GitHub Desktop.

Select an option

Save yorek/bf87857e0074fccec28c to your computer and use it in GitHub Desktop.
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()
@yorek

yorek commented Apr 26, 2022 via email

Copy link
Copy Markdown
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment