Skip to content

Commit f9b9514

Browse files
authored
Get-SqlDscRSSetupConfiguration: Add additional properties to output (#2089)
- `Get-SqlDscRSSetupConfiguration` - Add additional properties to `Get-SqlDscRSSetupConfiguration` output.
1 parent 07955d0 commit f9b9514

File tree

5 files changed

+122
-14
lines changed

5 files changed

+122
-14
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1717
- `Get-SqlDscInstalledInstance` to retrieve installed SQL instances.
1818
- `Get-SqlDscRSSetupConfiguration` to retrieve the setup configuration of
1919
SQL Server Reporting Services or Power BI Report Server ([issue #2072](https://github.com/dsccommunity/SqlServerDsc/issues/2072)).
20+
- Add additional properties to `Get-SqlDscRSSetupConfiguration` output.
2021
- `Install-SqlDscReportingService` to install SQL Server Reporting Services
2122
([issue #2010](https://github.com/dsccommunity/SqlServerDsc/issues/2010)).
2223
- `Install-SqlDscBIReportServer` to install SQL Server BI Report Server.

source/Public/Get-SqlDscRSSetupConfiguration.ps1

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@
4949
- CurrentVersion: The current version from registry.
5050
- VirtualRootServer: The virtual root server value.
5151
- ConfigFilePath: The path to the report server configuration file.
52+
- EditionID: The edition ID of the Reporting Services instance.
53+
- EditionName: The edition name of the Reporting Services instance.
54+
- IsSharePointIntegrated: Whether the instance is SharePoint integrated.
55+
MSReportServer_Instance.
56+
- InstanceId: The instance ID of the Reporting Services instance.
5257
#>
5358
function Get-SqlDscRSSetupConfiguration
5459
{
@@ -87,16 +92,20 @@ function Get-SqlDscRSSetupConfiguration
8792
Write-Verbose -Message ($script:localizedData.Get_SqlDscRSSetupConfiguration_ProcessingInstance -f $instance.InstanceName)
8893

8994
$returnObject = [PSCustomObject]@{
90-
InstanceName = $instance.InstanceName
91-
InstallFolder = $null
92-
ServiceName = $null
93-
ErrorDumpDirectory = $null
94-
CurrentVersion = $null
95-
CustomerFeedback = $null
96-
EnableErrorReporting = $null
97-
ProductVersion = $null
98-
VirtualRootServer = $null
99-
ConfigFilePath = $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 = $null
100109
}
101110

102111
Write-Verbose -Message ($script:localizedData.Get_SqlDscRSSetupConfiguration_FoundInstance -f $instance.InstanceName)
@@ -150,6 +159,22 @@ function Get-SqlDscRSSetupConfiguration
150159
$getRegistryPropertyValueParameters.Name = 'ProductVersion'
151160
$returnObject.ProductVersion = Get-RegistryPropertyValue @getRegistryPropertyValueParameters
152161

162+
if (-not [System.String]::IsNullOrEmpty($returnObject.CurrentVersion))
163+
{
164+
$reportServerCurrentVersion = [System.Version] $returnObject.CurrentVersion
165+
166+
# 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+
169+
if ($msReportServerInstance)
170+
{
171+
$returnObject.EditionID = $msReportServerInstance.EditionID
172+
$returnObject.EditionName = $msReportServerInstance.EditionName
173+
$returnObject.IsSharePointIntegrated = $msReportServerInstance.IsSharePointIntegrated
174+
$returnObject.InstanceId = $msReportServerInstance.InstanceId
175+
}
176+
}
177+
153178
$reportingServicesInstances += $returnObject
154179
}
155180

tests/Integration/Commands/Get-SqlDscRSSetupConfiguration.Integration.Tests.ps1

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ Describe 'Get-SqlDscRSSetupConfiguration' {
4343
$result.EnableErrorReporting | Should -Be 1
4444
$result.VirtualRootServer | Should -Be 'ReportServer'
4545
$result.ConfigFilePath | Should -Be 'C:\Program Files\SSRS\SSRS\ReportServer\rsreportserver.config'
46+
$result.InstanceId | Should -Be 'SSRS'
47+
$result.EditionID | Should -Be 2176971986
48+
$result.EditionName | Should -Be 'SQL Server Developer'
49+
$result.IsSharePointIntegrated | Should -BeFalse
4650
}
4751
}
4852

@@ -65,6 +69,10 @@ Describe 'Get-SqlDscRSSetupConfiguration' {
6569
$result.EnableErrorReporting | Should -Be 1
6670
$result.VirtualRootServer | Should -Be 'ReportServer'
6771
$result.ConfigFilePath | Should -Be 'C:\Program Files\SSRS\SSRS\ReportServer\rsreportserver.config'
72+
$result.InstanceId | Should -Be 'SSRS'
73+
$result.EditionID | Should -Be 2176971986
74+
$result.EditionName | Should -Be 'SQL Server Developer'
75+
$result.IsSharePointIntegrated | Should -BeFalse
6876
}
6977
}
7078

@@ -87,12 +95,18 @@ Describe 'Get-SqlDscRSSetupConfiguration' {
8795
$result.EnableErrorReporting | Should -Be 1
8896
$result.VirtualRootServer | Should -Be 'ReportServer'
8997
$result.ConfigFilePath | Should -Be 'C:\Program Files\SSRS\SSRS\ReportServer\rsreportserver.config'
98+
$result.InstanceId | Should -Be 'SSRS'
99+
$result.EditionID | Should -Be 2176971986
100+
$result.EditionName | Should -Be 'SQL Server Developer'
101+
$result.IsSharePointIntegrated | Should -BeFalse
90102
}
91103
}
92104

93105
Context 'When getting the configuration for Power BI Report Server instance' -Tag @('Integration_PowerBI') {
94106
# cSpell: ignore PBIRS rsreportserver
95107
It 'Should return the correct configuration for PBIRS instance' {
108+
#Write-Verbose -Message ((reg query "HKLM\SOFTWARE\Microsoft\Microsoft SQL Server" /s) | Out-String) -Verbose
109+
96110
# Get the PBIRS configuration
97111
$result = Get-SqlDscRSSetupConfiguration -InstanceName 'PBIRS'
98112

@@ -108,6 +122,10 @@ Describe 'Get-SqlDscRSSetupConfiguration' {
108122
$result.EnableErrorReporting | Should -Be 1
109123
$result.VirtualRootServer | Should -Be 'ReportServer'
110124
$result.ConfigFilePath | Should -Be 'C:\Program Files\PBIRS\PBIRS\ReportServer\rsreportserver.config'
125+
$result.InstanceId | Should -Be 'PBIRS'
126+
$result.EditionID | Should -Be 2017617798
127+
$result.EditionName | Should -Be 'Power BI Report Server - Developer'
128+
$result.IsSharePointIntegrated | Should -BeFalse
111129
}
112130
}
113131

tests/Integration/Commands/Install-SqlDscBIReportServer.Integration.Tests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Describe 'Install-SqlDscBIReportServer' -Tag @('Integration_PowerBI') {
4242
AcceptLicensingTerms = $true
4343
MediaPath = $powerBIReportServerExecutable
4444
InstallFolder = 'C:\Program Files\PBIRS'
45-
Edition = 'Evaluation'
45+
Edition = 'Developer'
4646
LogPath = Join-Path -Path $script:temporaryFolder -ChildPath 'PowerBIReportServer_Install.log'
4747
SuppressRestart = $true
4848
Verbose = $true

tests/Unit/Public/Get-SqlDscRSSetupConfiguration.Tests.ps1

Lines changed: 67 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,38 @@ AfterAll {
4747
}
4848

4949
Describe 'Get-SqlDscRSSetupConfiguration' {
50+
BeforeAll {
51+
InModuleScope -ScriptBlock {
52+
function script:Get-CimInstance
53+
{
54+
param
55+
(
56+
[System.String]
57+
$ClassName,
58+
59+
[System.String]
60+
$Namespace
61+
)
62+
63+
$PSCmdlet.ThrowTerminatingError(
64+
[System.Management.Automation.ErrorRecord]::new(
65+
'StubNotImplemented',
66+
'StubCalledError',
67+
[System.Management.Automation.ErrorCategory]::InvalidOperation,
68+
$MyInvocation.MyCommand
69+
)
70+
)
71+
72+
}
73+
}
74+
}
75+
76+
AfterAll {
77+
InModuleScope -ScriptBlock {
78+
Remove-Item -Path 'function:script:Get-CimInstance' -Force
79+
}
80+
}
81+
5082
Context 'When getting all Reporting Services instances' {
5183
# cSpell: ignore PBIRS rsreportserver
5284
BeforeAll {
@@ -166,6 +198,15 @@ Describe 'Get-SqlDscRSSetupConfiguration' {
166198
} -MockWith {
167199
return $mockProductVersion
168200
}
201+
202+
Mock -CommandName Get-CimInstance -MockWith {
203+
return [PSCustomObject] @{
204+
EditionID = 2176971986
205+
EditionName = 'SQL Server Developer'
206+
IsSharePointIntegrated = $false
207+
InstanceId = 'SSRS'
208+
}
209+
}
169210
}
170211

171212
It 'Should return all Reporting Services instances' {
@@ -184,6 +225,10 @@ Describe 'Get-SqlDscRSSetupConfiguration' {
184225
$result[0].EnableErrorReporting | Should -Be $mockEnableErrorReporting
185226
$result[0].CurrentVersion | Should -Be $mockCurrentVersion
186227
$result[0].ProductVersion | Should -Be $mockProductVersion
228+
$result[0].EditionID | Should -Be 2176971986
229+
$result[0].EditionName | Should -Be 'SQL Server Developer'
230+
$result[0].IsSharePointIntegrated | Should -BeFalse
231+
$result[0].InstanceId | Should -Be 'SSRS'
187232

188233
$result[1].InstanceName | Should -Be $mockPBIRSInstance.InstanceName
189234
$result[1].InstallFolder | Should -Be $mockInstallFolder
@@ -195,6 +240,10 @@ Describe 'Get-SqlDscRSSetupConfiguration' {
195240
$result[1].EnableErrorReporting | Should -Be $mockEnableErrorReporting
196241
$result[1].CurrentVersion | Should -Be $mockCurrentVersion
197242
$result[1].ProductVersion | Should -Be $mockProductVersion
243+
$result[0].EditionID | Should -Be 2176971986
244+
$result[0].EditionName | Should -Be 'SQL Server Developer'
245+
$result[0].IsSharePointIntegrated | Should -BeFalse
246+
$result[0].InstanceId | Should -Be 'SSRS'
198247

199248
Should -Invoke -CommandName Get-SqlDscInstalledInstance -ParameterFilter {
200249
$ServiceType -eq 'ReportingServices' -and
@@ -211,17 +260,32 @@ Describe 'Get-SqlDscRSSetupConfiguration' {
211260
$mockSSRSInstance = @{
212261
InstanceName = 'SSRS'
213262
ServiceName = 'ReportServer'
263+
CurrentVersion = '15.0.1.0'
214264
}
215265

216266
# Mock registry values
217-
$mockInstallFolder = 'C:\Program Files\Microsoft SQL Server Reporting Services'
267+
#$mockInstallFolder = 'C:\Program Files\Microsoft SQL Server Reporting Services'
218268

219269
Mock -CommandName Get-SqlDscInstalledInstance -MockWith {
220270
return @($mockSSRSInstance)
221271
}
222272

223-
Mock -CommandName Get-RegistryPropertyValue -MockWith {
224-
return $mockInstallFolder
273+
Mock -CommandName Get-RegistryPropertyValue
274+
Mock -CommandName Get-RegistryPropertyValue -ParameterFilter {
275+
$Path -eq 'HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\SSRS\MSSQLServer\CurrentVersion' -and
276+
$Name -eq 'CurrentVersion'
277+
} -MockWith {
278+
return '15.0.1.0'
279+
}
280+
281+
Mock -CommandName Get-CimInstance -MockWith {
282+
return [PSCustomObject] @{
283+
EditionID = 2176971986
284+
EditionName = 'SQL Server Developer'
285+
IsSharePointIntegrated = $false
286+
Version = '15.0.1.0'
287+
InstanceId = 'SSRS'
288+
}
225289
}
226290
}
227291

0 commit comments

Comments
 (0)