try 连接到表格模型并在分析服务表格模型上创建分区.下面提到的这段代码.
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.AnalysisServices.Tabular")
#Here, the variables are declared to be used
$ServerName = "<analysis SERVICE URI>"
$DatabaseName = "ProductReportingModelPartitionTest"
$Server = New-Object Microsoft.AnalysisServices.Tabular.Server
#Connecting to the Tabular Server
$Server.Connect("$ServerName")
#Declaring which Tabular database to connect to
$DatabaseName = $Server.Databases["$DatabaseName"]
$Model = $DatabaseName.Model
function Add-NewPartition ($_table,$_originalPartition) {
#Find the partition by name in the model
$PartitionExists = $_table.Partitions.Find("DevPartition")
echo($PartitionExists | Format-Table)
#Check if the partition was already created, if not exit.
if (!$PartitionExists)
{
#Clone the reference partition that has placeholder 1=2
$NewPartition = $_originalPartition.Clone()
#Give a name to the new partition, something that can be found
$NewPartition.Name = "deve0osl"
#Add the new partition
$_table.Partitions.Add( $NewPartition )
#Call the refresh data process method to refresh the data of the new partition
$NewPartition.RequestRefresh("Data")
}
}
$Table = $Model.Tables["Online Stock - Seasons"]
$OriginalPartition = $Table.Partitions[0]
Add-NewPartition $Table $OriginalPartition
直到$NewPartition开始工作.但$_table.Partitions.Add( $NewPartition )
美元不管用.请帮帮忙,提前谢谢.