您无法在PowerShell中对空值表达式调用方法

时间:2016-09-14 11:54:10

标签: powershell ssas msas

这是我在PS中的代码:

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.AnalysisServices.Tabular")
$serverName = "panya\taylor";
$databaseName = "FreshDesk";
$tableName = "Metrics";
$measureName = "TestAuto";
$measureExpression = "SUMX ( FactTickets, FactTickets[PriorityID] * FactTickets[StatusID] )";

$svr = new-Object Microsoft.AnalysisServices.Tabular.Server
$svr.Connect($serverName)
$database = $svr.databases
$db = $database.GetByName($databaseName)
$table = $db.Model.Tables.Item($tableName)
$measure = new-Object Microsoft.AnalysisServices.Tabular.Measure
$measure.Name = $measureName
$measure.Expression = $measureExpression
$table.Measures.Add( $measure )
$db.Model.SaveChanges()

然而,它给了我一个错误You cannot call a method on a null-valued expression.无法弄明白。这一行引发了错误:

$table = $db.Model.Tables.Item($tableName)

但这里使用的变量都不是NULL

0 个答案:

没有答案