Skip to content

Commit 0688805

Browse files
authored
Get-SqlDscRSSetupConfiguration: Fix for the SSRS 2016 case (#2347)
1 parent ef9ae5f commit 0688805

File tree

3 files changed

+305
-40
lines changed

3 files changed

+305
-40
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
129129

130130
### Fixed
131131

132+
- `Get-SqlDscRSSetupConfiguration`
133+
- Fixed issue where the function doesn't provide an output for SSRS 2016 instances
134+
because registry paths were using `InstanceName` instead of `InstanceId`.
135+
[issue #2346](https://github.com/dsccommunity/SqlServerDsc/issues/2346).
136+
- Added fallback to `SQLPath` registry value for SQL 2016 and earlier when
137+
`InstallRootDirectory` is not found [issue #2346](https://github.com/dsccommunity/SqlServerDsc/issues/2346).
138+
- Added filtering to `MSReportServer_Instance` retrieval logic to handle the case
139+
with many SSRSs.
132140
- `SqlRS`
133141
- Obtain the Reporting service name from WMI for version 14 and higher.
134142
[issue #2313](https://github.com/dsccommunity/SqlServerDsc/issues/2313)

source/Public/Get-SqlDscRSSetupConfiguration.ps1

Lines changed: 34 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -92,20 +92,20 @@ function Get-SqlDscRSSetupConfiguration
9292
Write-Verbose -Message ($script:localizedData.Get_SqlDscRSSetupConfiguration_ProcessingInstance -f $instance.InstanceName)
9393

9494
$returnObject = [PSCustomObject]@{
95-
InstanceName = $instance.InstanceName
96-
InstallFolder = $null
97-
ServiceName = $null
98-
ErrorDumpDirectory = $null
99-
CurrentVersion = $null
100-
CustomerFeedback = $null
101-
EnableErrorReporting = $null
102-
ProductVersion = $null
103-
VirtualRootServer = $null
104-
ConfigFilePath = $null
105-
EditionID = $null
106-
EditionName = $null
107-
IsSharePointIntegrated = $null
108-
InstanceId = $null
95+
InstanceName = $instance.InstanceName
96+
InstallFolder = $null
97+
ServiceName = $null
98+
ErrorDumpDirectory = $null
99+
CurrentVersion = $null
100+
CustomerFeedback = $null
101+
EnableErrorReporting = $null
102+
ProductVersion = $null
103+
VirtualRootServer = $null
104+
ConfigFilePath = $null
105+
EditionID = $null
106+
EditionName = $null
107+
IsSharePointIntegrated = $null
108+
InstanceId = $instance.InstanceId
109109
}
110110

111111
Write-Verbose -Message ($script:localizedData.Get_SqlDscRSSetupConfiguration_FoundInstance -f $instance.InstanceName)
@@ -115,11 +115,21 @@ function Get-SqlDscRSSetupConfiguration
115115
}
116116

117117
# Get values from SSRS\Setup registry key
118-
$getRegistryPropertyValueParameters.Path = 'HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\{0}\Setup' -f $instance.InstanceName
118+
$getRegistryPropertyValueParameters.Path = 'HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\{0}\Setup' -f $returnObject.InstanceId
119119

120120
# InstallRootDirectory
121121
$getRegistryPropertyValueParameters.Name = 'InstallRootDirectory'
122122
$returnObject.InstallFolder = Get-RegistryPropertyValue @getRegistryPropertyValueParameters
123+
# Fallback to SQLPath if InstallRootDirectory is not found. This is the case for SQL 2016 and earlier.
124+
if ($null -eq $returnObject.InstallFolder)
125+
{
126+
$getRegistryPropertyValueParameters.Name = 'SQLPath'
127+
$returnObject.InstallFolder = Get-RegistryPropertyValue @getRegistryPropertyValueParameters
128+
if (($null -ne $returnObject.InstallFolder) -and ($returnObject.InstallFolder -notmatch '^[A-Za-z]:\\?$'))
129+
{
130+
$returnObject.InstallFolder = $returnObject.InstallFolder.TrimEnd('\')
131+
}
132+
}
123133

124134
# ServiceName
125135
$getRegistryPropertyValueParameters.Name = 'ServiceName'
@@ -134,7 +144,7 @@ function Get-SqlDscRSSetupConfiguration
134144
$returnObject.ConfigFilePath = Get-RegistryPropertyValue @getRegistryPropertyValueParameters
135145

136146
# Get values from SSRS\CPE registry key
137-
$getRegistryPropertyValueParameters.Path = 'HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\{0}\CPE' -f $instance.InstanceName
147+
$getRegistryPropertyValueParameters.Path = 'HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\{0}\CPE' -f $returnObject.InstanceId
138148

139149
# ErrorDumpDir
140150
$getRegistryPropertyValueParameters.Name = 'ErrorDumpDir'
@@ -149,7 +159,7 @@ function Get-SqlDscRSSetupConfiguration
149159
$returnObject.EnableErrorReporting = Get-RegistryPropertyValue @getRegistryPropertyValueParameters
150160

151161
# Get values from SSRS\MSSQLServer\CurrentVersion registry key
152-
$getRegistryPropertyValueParameters.Path = 'HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\{0}\MSSQLServer\CurrentVersion' -f $instance.InstanceName
162+
$getRegistryPropertyValueParameters.Path = 'HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\{0}\MSSQLServer\CurrentVersion' -f $returnObject.InstanceId
153163

154164
# CurrentVersion from registry
155165
$getRegistryPropertyValueParameters.Name = 'CurrentVersion'
@@ -164,8 +174,13 @@ function Get-SqlDscRSSetupConfiguration
164174
$reportServerCurrentVersion = [System.Version] $returnObject.CurrentVersion
165175

166176
# Get values from MSReportServer_Instance
167-
$msReportServerInstance = Get-CimInstance -Namespace ('root\Microsoft\SqlServer\ReportServer\RS_{0}\v{1}' -f $instance.InstanceName, $reportServerCurrentVersion.Major) -ClassName 'MSReportServer_Instance' -ErrorAction 'SilentlyContinue'
168-
177+
$getCimInstanceParameters = @{
178+
Filter = "InstanceId='{0}'" -f $returnObject.InstanceId
179+
Namespace = 'root\Microsoft\SqlServer\ReportServer\RS_{0}\v{1}' -f $instance.InstanceName, $reportServerCurrentVersion.Major
180+
ClassName = 'MSReportServer_Instance'
181+
ErrorAction = 'SilentlyContinue'
182+
}
183+
$msReportServerInstance = Get-CimInstance @getCimInstanceParameters
169184
if ($msReportServerInstance)
170185
{
171186
$returnObject.EditionID = $msReportServerInstance.EditionID

0 commit comments

Comments
 (0)