From 9dbcd1279281602bc484941bfb0c6a4a1050fb04 Mon Sep 17 00:00:00 2001 From: Marko Bozikovic Date: Wed, 24 May 2017 15:20:13 +0100 Subject: [PATCH] [#569] A fix for SQL 2016 virtual directory name change. --- CHANGELOG.md | 3 ++- .../MSFT_xSQLServerRSConfig.psm1 | 16 +++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 48e16cd707..062efe2049 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -56,7 +56,8 @@ - When TcpDynamicPorts is set to '0' the Test-TargetResource function will no longer fail each time (issue #564). - Changes to xSQLServerRSConfig - Replaced sqlcmd.exe usages with Invoke-Sqlcmd calls (issue #567). - - $SQLAdminCredential is now optional. To use the credential, CredSSP authentication must be properly configured on the target node. + - $SQLAdminCredential is now optional. To use the credential, CredSSP authentication must be properly configured on the target node. + - fixed virtual directory creation for SQL Server 2016 ## 7.0.0.0 diff --git a/DSCResources/MSFT_xSQLServerRSConfig/MSFT_xSQLServerRSConfig.psm1 b/DSCResources/MSFT_xSQLServerRSConfig/MSFT_xSQLServerRSConfig.psm1 index e36c713611..8975152b40 100644 --- a/DSCResources/MSFT_xSQLServerRSConfig/MSFT_xSQLServerRSConfig.psm1 +++ b/DSCResources/MSFT_xSQLServerRSConfig/MSFT_xSQLServerRSConfig.psm1 @@ -109,7 +109,7 @@ function Set-TargetResource $invokeParameters.Add("Authentication", "CredSSP") } - Invoke-Command @invokeParameters -ScriptBlock { + $null = Invoke-Command @invokeParameters -ScriptBlock { # this is a separate PS session, need to load Common Code again Import-Module $using:currentPath\..\..\xSQLServerHelper.psm1 -Verbose -ErrorAction Stop # smart import of the SQL module @@ -119,7 +119,7 @@ function Set-TargetResource $RSSQLServer = $args[1] $RSSQLInstanceName = $args[2] $InstanceKey = (Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\Instance Names\RS" -Name $InstanceName).$InstanceName - $SQLVersion = ((Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\$InstanceKey\Setup" -Name "Version").Version).Split(".")[0] + $SQLVersion = [int]((Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\$InstanceKey\Setup" -Name "Version").Version).Split(".")[0] if($InstanceName -eq "MSSQLSERVER") { $RSServiceName = "ReportServer" @@ -146,13 +146,16 @@ function Set-TargetResource $RSConfig = Get-WmiObject -Class MSReportServer_ConfigurationSetting -Namespace "root\Microsoft\SQLServer\ReportServer\RS_$InstanceName\v$SQLVersion\Admin" if($RSConfig.VirtualDirectoryReportServer -ne $RSVirtualDirectory) { - $null = $RSConfig.SetVirtualDirectory("ReportServerWebService",$RSVirtualDirectory,$Language) - $null = $RSConfig.ReserveURL("ReportServerWebService","http://+:80",$Language) + $RSConfig.SetVirtualDirectory("ReportServerWebService",$RSVirtualDirectory,$Language) + $RSConfig.ReserveURL("ReportServerWebService","http://+:80",$Language) } if($RSConfig.VirtualDirectoryReportManager -ne $RMVirtualDirectory) { - $null = $RSConfig.SetVirtualDirectory("ReportManager",$RMVirtualDirectory,$Language) - $null = $RSConfig.ReserveURL("ReportManager","http://+:80",$Language) + # SSRS Web Portal application name changed in SQL Server 2016 + # https://docs.microsoft.com/en-us/sql/reporting-services/breaking-changes-in-sql-server-reporting-services-in-sql-server-2016 + $virtualDirectoryName = if ($SQLVersion -ge 13) { 'ReportServerWebApp' } else { 'ReportManager'} + $RSConfig.SetVirtualDirectory($virtualDirectoryName,$RMVirtualDirectory,$Language) + $RSConfig.ReserveURL($virtualDirectoryName,"http://+:80",$Language) } $RSCreateScript = $RSConfig.GenerateDatabaseCreationScript($RSDatabase,$Language,$false) @@ -164,7 +167,6 @@ function Set-TargetResource Invoke-Sqlcmd -ServerInstance $RSConnection -Query $RSRightsScript.Script $RSConfig.SetDatabaseConnection($RSConnection,$RSDatabase,2,"","") $RSConfig.InitializeReportServer($RSConfig.InstallationID) - } }