这是我的情况:我必须设置一个号码TFS 2013应用程序层节点(至少6位)的,我想这个过程自动化,节点的主机也SQL Server报表服务2012 SP1中的“簇”(更好组)配置。 我在安装SQL没问题,但我坚持Reporting Services配置。
该文档的状态使用WMI配置URL和MSReportServer_ConfigurationSetting类有一个SetVirtualDirectory这似乎是适当的。 我看到价值变动RS配置管理器,但该消息
报表服务器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
找到罪魁祸首:需要调用ReserveURL并使用http://+:80
语法的URL。 调用此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)
我在数据中心工作,之前发现这个方法,我用了一个AutoIt的程序来配置SSRS实例。
我想加入到这个解决方案的事是配置SSL,它可以如下完成
$certhash = Get-ChildItem -path cert:\localmachine\my | Where {$_.subject -match <yourdomain> } | select -ExpandProperty thumbprint
$certhash = $certhash.tolower() #important
$sslPort = 443
$sslUrl = "https://+:443/"
$lcid = 1033 # for english
$rsConfig.ReserveURL("ReportServerWebService", $sslUrl, $lcid)
$rsConfig.CreateSSLCertificateBinding("ReportServerWebService", $certHash, "0.0.0.0", $sslPort, $lcid)
$rsConfig.ReserveURL("ReportManager", $sslUrl, $lcid)
$rsConfig.CreateSSLCertificateBinding("ReportManager", $certHash, "0.0.0.0", $sslPort, $lcid)
# Stop and Start SQL Server's Reporting Services to ensure changes take affect
$rsconfig.SetServiceState($false, $false, $false)
$rsconfig.SetServiceState($true, $true, $true)
其他一些非常有用的资源
http://babercode.blogspot.com/2012/03/powershell-report-server-integration_21.html
https://ruiromanoblog.wordpress.com/2010/05/08/configure-reporting-services-ssl-binding-with-wmi-powershell/