SQL Server 2022 Reporting Services中通过PowerShell生成SSAS数据源模型失败的问题求助
SQL Server 2022 Reporting Services中通过PowerShell生成SSAS数据源模型失败的问题求助
我们的应用目前运行在SQL Server 2014,正计划迁移到SQL Server 2022。最近尝试用PowerShell从SSRS的数据源生成模型,但一直失败,报错提示:
"System.ArgumentException: The connection cannot be recognized as a connection to Analysis Services Server."
以下是我使用的PowerShell代码:
$url = "https://localhost/ReportServer_NamedInstance/reportservice2010.asmx?WSDL" $ssrs = New-WebServiceProxy -uri $url -UseDefaultCredential #create data source $dataSourceDefinitionType = ($type + '.DataSourceDefinition'); $dataSourceDefinition = new-object ($dataSourceDefinitionType); $dataSourceDefinition.Extension = "OLEDB-MD" $dataSourceDefinition.ConnectString = "Data Source=localhost\NamedInstance; Initial Catalog=SAMPLE_DB_OLAP" $dataSourceDefinition.CredentialRetrieval = 'Integrated' $newDataSource = $ssrs.CreateDataSource("SAMPLE_DB_OLAP", "/", $true, $dataSourceDefinition, $null); # create model $warnings = @() $dataSourceName = "/SAMPLE_DB_OLAP" $ssrs.GenerateModel("SAMPLE_DB_OLAP", "SampleDbOlapModel", "/", $null, [ref] $warnings)
完整的错误堆栈信息如下:
Exception calling "GenerateModel" with "5" argument(s): "System.Web.Services.Protocols.SoapException: An error occurred while generating model. ---> Microsoft.ReportingServices.Diagnostics.Utilities.ModelGenerationErrorException: An error occurred while generating model. ---> System.ArgumentException: The connection cannot be recognized as a connection to Analysis Services Server. at Microsoft.ReportingServices.Library.ReportingService2010Impl.GenerateModel(String DataSource, String Model, String Parent, Property[] Properties, CatalogItem& ItemInfo, Warning[]& Warnings) at Microsoft.ReportingServices.WebServer.ReportingService2010.GenerateModel(String DataSource, String Model, String Parent, Property[] Properties, CatalogItem& ItemInfo, Warning[]& Warnings)" At line:1 char:1 + $ssrs.GenerateModel("...)
我们已经尝试了以下几种方法,但都没有解决问题:
- 生成指向普通关系型数据库(非SSAS/OLAP)的数据源模型,命令可以成功执行,说明PowerShell脚本本身没有问题
- 修改连接字符串,尝试添加指定Provider(比如
Provider=MSOLEDBSQL;Data Source=localhost\NamedInstance; Initial Catalog=SAMPLE_DB_OLAP),但不管怎么调整连接字符串的格式,SSRS都无法识别这是一个SSAS服务器的连接 - 用dotPeek反编译相关DLL查找错误来源,发现抛出这个错误的逻辑大致是:判断连接是否为
AdomdConnection,如果不是就抛出该ArgumentException,但没有找到进一步的解决线索
想请教一下,有没有人成功在SQL Server 2022环境中,通过PowerShell为SSAS数据源生成过模型?
备注:内容来源于stack exchange,提问作者Wtflmtfa
相关产品推荐
相关产品推荐

