sql-server - 意外 token 'UpdateOptions.ExpandFull'

标签 sql-server powershell azure-analysis-services

基于https://learn.microsoft.com/en-us/bi-reference/tom/add-a-data-source-to-tabular-model-analysis-services-amo-tom

我正在尝试更新数据库连接字符串更改:

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/

相关文章:

sql-server - 如何高效存储和查询十亿行传感器数据

javascript - 从 Node.js 连接 Azure 分析服务

sql - Entity Framework 迁移 - 分支管理

sql-server - 什么是 SQL Server Rand 函数算法?

powershell - 如何在powershell中遵循快捷方式

c# - 如何在C#中将参数添加到powershellinstance

powershell - 我想检查数组中是否存在元素

azure - M 分区使用的数据函数会导致访问与模型中定义的数据源不同的数据源

sql-server - 如何将文件内容读入 SQL 变量