我正在尝试静默安装和配置SQL Server 2017 Reporting Services。静默安装很简单,我使用下面的PowerShell脚本完成了大部分配置。
我遇到问题的地方是尝试设置报表管理器的虚拟目录。我在以下行收到错误
$configset.SetVirtualDirectory("ReportManager", "Reports", 1033)
HRESULT -2147220938:找不到该应用程序。
根据How to automate SSRS install and configuration,我似乎正在以正确的顺序执行这些步骤。
$configset = Get-WmiObject –namespace "root\Microsoft\SqlServer\ReportServer\RS_SSRS\v14\Admin" `
-class MSReportServer_ConfigurationSetting -ComputerName localhost
$configset
If (! $configset.IsInitialized)
{
[string]$dbscript = $configset.GenerateDatabaseCreationScript("ReportServer", 1033, $false).Script
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force
Import-Module sqlps -DisableNameChecking | Out-Null
$conn = New-Object Microsoft.SqlServer.Management.Common.ServerConnection -ArgumentList $env:ComputerName
$conn.ApplicationName = "Script"
$conn.StatementTimeout = 0
$conn.Connect()
$smo = New-Object Microsoft.SqlServer.Management.Smo.Server -ArgumentList $conn
# Create the ReportServer and ReportServerTempDB databases
$db = $smo.Databases["master"]
$db.ExecuteNonQuery($dbscript)
# Set permissions for the databases
$dbscript = $configset.GenerateDatabaseRightsScript($configset.WindowsServiceIdentityConfigured, "ReportServer", $false, $true).Script
$db.ExecuteNonQuery($dbscript)
# Set the database connection info
$configset.SetDatabaseConnection("(local)", "ReportServer", 2, "", "")
$configset.SetVirtualDirectory("ReportServerWebService", "ReportServer", 1033)
$configset.ReserveURL("ReportServerWebService", "http://+:80", 1033)
$configset.SetVirtualDirectory("ReportManager", "Reports", 1033)
$configset.ReserveURL("ReportManager", "http://+:80", 1033)
$configset.InitializeReportServer($configset.InstallationID)
$configset.IsReportManagerEnabled
$configset.IsInitialized
$configset.IsWebServiceEnabled
$configset.IsWindowsServiceEnabled
$configset.ListReportServersInDatabase()
$configset.ListReservedUrls();
$inst = Get-WmiObject –namespace "root\Microsoft\SqlServer\ReportServer\RS_SSRS\v14" `
-class MSReportServer_Instance -ComputerName localhost
$inst.GetReportServerUrls()
}
对此问题的任何见解表示赞赏!
你可以使用DSC这个链接应该有关于如何使用dsc资源的信息:
当这段代码是Xrev时,我能够使用当时名为MSFT_xSQLServerSetup的资源安装和配置SSRS。
以下是设置单个sql server的示例。 https://github.com/PowerShell/SqlServerDsc/blob/master/Examples/SQL-Standalone.ps1
问题出在SQL Server 2016(及更高版本)上,报表管理器的Web应用程序名称已从ReportManager
更改为ReportServerWebApp
。