如何自动化SSRS安装和配置

时间:2014-08-05 09:38:12

标签: reporting-services tfs automation

这是我的方案:我必须设置一些TFS 2013应用程序层节点(至少6个),我正在尝试自动化该过程,节点还承载SQL Server Reporting Services 2012 SP1" cluster& #34; (更好的组)配置。我在安装SQL方面没有问题,但我仍然坚持使用Reporting Services配置。

documentation表示使用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

3 个答案:

答案 0 :(得分:5)

找到了罪魁祸首:需要调用ReserveURL并使用URL的http://+:80语法。调用此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)

答案 1 :(得分:3)

我在数据中心工作,在发现此方法之前,我使用了一个自动程序来配置SSRS实例。

我想在此解决方案中添加的是配置SSL,可以按照以下步骤进行操作

import collections
import re

Token = collections.namedtuple('Token', ['typ', 'value', 'line', 'column'])

def tokenize(code):
    token_specification = [
        # regexes suggested from [Thomas Ayoub][3]
        ('BOTH',      r'([\'"]{3}).*?\2'), # for both triple-single quotes and triple-double quotes
        ('SINGLE',    r"('''.*?''')"),     # triple-single quotes 
        ('DOUBLE',    r'(""".*?""")'),     # triple-double quotes 
        # regexes which match OK
        ('COM',       r'#.*'),
        ('NUMBER',  r'\d+(\.\d*)?'),  # Integer or decimal number
        ('ASSIGN',  r':='),           # Assignment operator
        ('END',     r';'),            # Statement terminator
        ('ID',      r'[A-Za-z]+'),    # Identifiers
        ('OP',      r'[+\-*/]'),      # Arithmetic operators
        ('NEWLINE', r'\n'),           # Line endings
        ('SKIP',    r'[ \t]+'),       # Skip over spaces and tabs
        ('MISMATCH',r'.'),            # Any other character
    ]

    test_regexes = ['COM', 'BOTH', 'SINGLE', 'DOUBLE']

    tok_regex = '|'.join('(?P<%s>%s)' % pair for pair in token_specification)
    line_num = 1
    line_start = 0
    for mo in re.finditer(tok_regex, code):
        kind = mo.lastgroup
        value = mo.group(kind)
        if kind == 'NEWLINE':
            line_start = mo.end()
            line_num += 1
        elif kind == 'SKIP':
            pass
        elif kind == 'MISMATCH':
            pass
        else:
            if kind in test_regexes:
                print(kind, value)
            column = mo.start() - line_start
            yield Token(kind, value, line_num, column)

f = r'C:\path_to_python_file_with_above_examples'

with open(f) as sfile:
    content = sfile.read()

for t in tokenize(content):
    pass #print(t)

其他一些非常有用的资源是

  

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/

答案 2 :(得分:0)

因此,我刚刚找到一个PowerShell模块来帮助通过脚本进行配置。在幕后,它使用WMI并且不完整(没有证书方法),但是比以前更加简洁。

该模块,来自Microsoft:ReportingServicesTools

最后,如果您的设置需要SSL,则以下代码应会有所帮助。它的灵感来自this post

e: /home/work/users/alex/broken-test-fixtures/src/test/kotlin/SayHelloTest.kt: (10, 22): Cannot access 'sayHello': it is internal in 'org.example.broken_test_fixtures'

请注意,脚本在SSRS的版本中会有所不同,因此您的里程可能会有所不同。