如何自动化SSRS安装和配置

Giu*_*ian 1 tfs automation reporting-services

这是我的方案:我必须设置许多TFS 2013应用程序层节点(至少6个),我正在尝试自动化该过程,节点还在"集群"(更好的组)配置中承载SQL Server Reporting Services 2012 SP1 .我在安装SQL时没有问题,但我仍然坚持使用Reporting Services配置.

文档的状态使用WMI配置URL和MSReportServer_ConfigurationSetting类有一个SetVirtualDirectory这似乎是适当的.我看到RS Configuration Manager中的值发生了变化,但是消息

未配置报表服务器Web服务.

不要消失.

我的Powershell代码是

$wmiName = (Get-WmiObject –namespace root\Microsoft\SqlServer\ReportServer  –class __Namespace).Name
$rsConfig = Get-WmiObject –namespace "root\Microsoft\SqlServer\ReportServer\$wmiName\v11\Admin" -class MSReportServer_ConfigurationSetting  -filter "InstanceName='SQLTFS'"

CheckHResult $rsConfig.SetVirtualDirectory("ReportServerWebService","ReportServer",0)
CheckHResult $rsConfig.SetVirtualDirectory("ReportManager","Reports",0)
CheckHResult $rsConfig.SetDatabaseConnection($DatabaseInstance, $DatabaseName, 2, $SqlCredential.UserName, $SqlCredential.GetNetworkCredential().Password)
# force refresh
CheckHResult $rsConfig.SetServiceState($false,$false,$false)
Restart-Service $rsConfig.ServiceName
CheckHResult $rsConfig.SetServiceState($true,$true,$true)
# set key
& "$SQLBin\RSKeyMgmt.exe" -a -i SQLTFS -f $SSRSEncryptKeyFile -p $SSRSEncryptPassword
# join group
& "$SQLBin\RSKeyMgmt.exe" -j -m $workingNode -i SQLTFS -n SQLTFS
Run Code Online (Sandbox Code Playgroud)

Giu*_*ian 5

找到了罪魁祸首:需要调用ReserveURL并使用http://+:80URL 的语法.调用此API会重新启动服务,因此可能需要一段时间才能响应.

新版脚本是

$wmiName = (Get-WmiObject –namespace root\Microsoft\SqlServer\ReportServer  –class __Namespace).Name

$rsConfig = Get-WmiObject –namespace "root\Microsoft\SqlServer\ReportServer\$wmiName\v11\Admin" -class MSReportServer_ConfigurationSetting -filter "InstanceName='SQLTFS'"
CheckHResult $rsConfig.SetDatabaseConnection($DatabaseInstance, $DatabaseName, 2, $SqlCredential.UserName, $SqlCredential.GetNetworkCredential().Password)

CheckHResult $rsConfig.SetVirtualDirectory("ReportServerWebService","ReportServer",$lcid)
CheckHResult $rsConfig.ReserveURL("ReportServerWebService","http://+:80",$lcid)
CheckHResult $rsConfig.SetVirtualDirectory("ReportManager","Reports",$lcid)
CheckHResult $rsConfig.ReserveURL("ReportManager","http://+:80",$lcid)

Start-Sleep -Seconds 15
# set key
& "$SQLBin\RSKeyMgmt.exe" -a -i SQLTFS -f $SSRSEncryptKeyFile -p $SSRSEncryptPassword
Start-Sleep -Seconds 15
# join group
& "$SQLBin\RSKeyMgmt.exe" -j -m $workingNode -i SQLTFS -n SQLTFS
Start-Sleep -Seconds 15

CheckHResult $rsConfig.SetServiceState($true,$true,$true)
Run Code Online (Sandbox Code Playgroud)