Creating SSAS 2008 cube partitions using Powershell?

How can we create SSAS 2008 cube partitions using Powershell?

+7
source share
3 answers

This adds the Adventure Works DW 2008R2 cube section (in particular, the Internet client measurement group in the Adventure Works cube):

$server_name = "localhost" $catalog = "Adventure Works DW 2008R2" $cube = "Adventure Works" $measure_group = "Fact Internet Sales" $old_partition = "Customers_2004" $new_partition = "Customers_2009" $old_text = "'2008" $new_text = "'2009" [Reflection.Assembly]::LoadFile("C:\Program Files\Microsoft SQL Server\100\SDK\Assemblies\Microsoft.AnalysisServices.DLL") $srv = new-object Microsoft.AnalysisServices.Server $srv.Connect("Data Source=" + $server_name) $new_part = $srv.Databases[$catalog].Cubes[$cube].MeasureGroups[$measure_group].Partitions[$old_partition].Clone() $new_part.ID = $new_partition $new_part.Name = $new_partition $new_part.Source.QueryDefinition = $new_part.Source.QueryDefinition.Replace($old_text, $new_text) $srv.Databases[$catalog].Cubes[$cube].MeasureGroups[$measure_group].Partitions.Add($new_part) $srv.Databases[$catalog].Cubes[$cube].MeasureGroups[$measure_group].Partitions[$new_partition].Update() $srv.Databases[$catalog].Update() $srv.Disconnect() 

You will need to change the variables at the top and the link to the assembly Microsoft.AnalysisServices.dll , but, in addition, it will work peach.

The trick is to call the Update() object, and then the entire database.

If you want to process a new partition, you can do this with the following line up to $srv.Disconnect :

 $srv.Databases[$catalog].Cubes[$cube].MeasureGroups[$measure_group].Partitions[$new_partition].Process() 

You can learn more about Analysis Management Objects (AMOs) here .

+6
source

Departure: PowerSSAS

It does not have explicit support for adding partitions, so you may have to create an XMLA fragment to add the partition, and then use PowerSSAS to send it to the SSAS server.

+1
source

you can use:

 Microsoft.AnalysisServices.Deployment [ASdatabasefile] {[/s[:logfile]] | [/a] | [[/o[:output_script_file]] [/d]]} 

to deploy your cubic speaker using powershell.

-2
source

All Articles