Skip to content

Commit

Permalink
[dsccommunity#569] A fix for SQL 2016 virtual directory name change.
Browse files Browse the repository at this point in the history
  • Loading branch information
bozho committed May 24, 2017
1 parent b4014c6 commit 1d356b1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand All @@ -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)

Expand All @@ -164,7 +167,6 @@ function Set-TargetResource
Invoke-Sqlcmd -ServerInstance $RSConnection -Query $RSRightsScript.Script
$RSConfig.SetDatabaseConnection($RSConnection,$RSDatabase,2,"","")
$RSConfig.InitializeReportServer($RSConfig.InstallationID)

}
}

Expand Down

0 comments on commit 1d356b1

Please sign in to comment.