7

Powershellを使用してSSAS2008キューブパーティションを作成するにはどうすればよいですか?

4

3 に答える 3

6

これにより、Adventure Works DW 2008R2 キューブ (具体的には Adventure Works キューブの Internet Customers メジャー グループ) にパーティションが追加されます。

$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()

一番上の変数とアセンブリへの参照を変更する必要がありますがMicrosoft.AnalysisServices.dll、それ以外は非常にうまく機能します。

秘訣はUpdate()、変更されたオブジェクトを呼び出してから、データベース全体を呼び出すことです。

新しいパーティションも処理したい場合は、前に次の行を追加して実行できます$srv.Disconnect

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

分析管理オブジェクト (AMO) の詳細については、こちらをご覧ください。

于 2012-01-04T16:21:46.477 に答える
1

これをチェックしてください: PowerSSAS

明示的なパーティションの追加はサポートされていないため、おそらく XMLA スニペットを作成してパーティションの追加を行い、PowerSSAS を使用してそれを SSAS サーバーにプッシュする必要があります。

于 2011-12-22T22:48:59.607 に答える
-2

あなたが使用することができます:

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

powershell を使用してキューブ AS をデプロイします。

于 2012-12-12T21:43:48.557 に答える