我正在尝试更新数据库连接字符串更改:
Import-Module SqlServer
$newConnectionString = "Connection Timeout=60;User Id=SOME_NEW_ID;Data Source=10.10.19.10;Persist Security Info=True;Session Character Set=UTF8"
$svr = new-Object Microsoft.AnalysisServices.Tabular.Server
$svr.Connect("server1.domain.com")
$svr.databases[1].model.datasources[0].ConnectionString = $newConnectionString
$svr.Databases[1].model.datasources[0].Update(UpdateOptions.ExpandFull)
但我收到错误:
Unexpected token 'UpdateOptions.ExpandFull' in expression or statement.
如果我定期更新():
$svr.Databases[1].model.datasources[0].Update()
我明白了:
Method invocation failed because [Microsoft.AnalysisServices.Tabular.ProviderDataSource] does not contain a method named 'Update'
如果我尝试SaveChanges()
:
$svr.Databases[1].Model.SaveChanges()
我收到此错误:
The following exception occurred while retrieving member "SaveChanges": "Encountered an invalid type for a default value."
如果我尝试ExpandFull
$svr.Databases[1].model.datasources[0].Update(ExpandFull)
我明白了
Unexpected token 'ExpandFull' in expression or statement.
最佳答案
错误是您指定更新枚举的方式。
您直接使用 .NET 类型,并且必须了解/知道给定枚举所属的位置。在本例中,UpdateOptions 位于 Microsoft.AnalysisServices 命名空间中
已更新
Import-Module SqlServer
$newConnectionString = "Connection Timeout=60;User Id=SOME_NEW_ID;Data Source=10.10.19.10;Persist Security Info=True;Session Character Set=UTF8"
$svr = new-Object Microsoft.AnalysisServices.Tabular.Server
$svr.Connect("server1.domain.com")
$svr.databases[1].model.datasources[0].ConnectionString = $newConnectionString
$svr.Databases[1].Update([Microsoft.AnalysisServices.UpdateOptions]::ExpandFull)
关于sql-server - 意外 token 'UpdateOptions.ExpandFull',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53251381/