diff --git a/CHANGELOG.md b/CHANGELOG.md index e1610141ee..c49e120f8a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `Get-SqlDscInstalledInstance` to retrieve installed SQL instances. - `Get-SqlDscRSSetupConfiguration` to retrieve the setup configuration of SQL Server Reporting Services or Power BI Report Server ([issue #2072](https://github.com/dsccommunity/SqlServerDsc/issues/2072)). + - Add additional properties to `Get-SqlDscRSSetupConfiguration` output. - `Install-SqlDscReportingService` to install SQL Server Reporting Services ([issue #2010](https://github.com/dsccommunity/SqlServerDsc/issues/2010)). - `Install-SqlDscBIReportServer` to install SQL Server BI Report Server. diff --git a/source/Public/Get-SqlDscRSSetupConfiguration.ps1 b/source/Public/Get-SqlDscRSSetupConfiguration.ps1 index d853a80c28..793f24d0bc 100644 --- a/source/Public/Get-SqlDscRSSetupConfiguration.ps1 +++ b/source/Public/Get-SqlDscRSSetupConfiguration.ps1 @@ -49,6 +49,11 @@ - CurrentVersion: The current version from registry. - VirtualRootServer: The virtual root server value. - ConfigFilePath: The path to the report server configuration file. + - EditionID: The edition ID of the Reporting Services instance. + - EditionName: The edition name of the Reporting Services instance. + - IsSharePointIntegrated: Whether the instance is SharePoint integrated. + MSReportServer_Instance. + - InstanceId: The instance ID of the Reporting Services instance. #> function Get-SqlDscRSSetupConfiguration { @@ -87,16 +92,20 @@ function Get-SqlDscRSSetupConfiguration Write-Verbose -Message ($script:localizedData.Get_SqlDscRSSetupConfiguration_ProcessingInstance -f $instance.InstanceName) $returnObject = [PSCustomObject]@{ - InstanceName = $instance.InstanceName - InstallFolder = $null - ServiceName = $null - ErrorDumpDirectory = $null - CurrentVersion = $null - CustomerFeedback = $null - EnableErrorReporting = $null - ProductVersion = $null - VirtualRootServer = $null - ConfigFilePath = $null + InstanceName = $instance.InstanceName + InstallFolder = $null + ServiceName = $null + ErrorDumpDirectory = $null + CurrentVersion = $null + CustomerFeedback = $null + EnableErrorReporting = $null + ProductVersion = $null + VirtualRootServer = $null + ConfigFilePath = $null + EditionID = $null + EditionName = $null + IsSharePointIntegrated = $null + InstanceId = $null } Write-Verbose -Message ($script:localizedData.Get_SqlDscRSSetupConfiguration_FoundInstance -f $instance.InstanceName) @@ -150,6 +159,22 @@ function Get-SqlDscRSSetupConfiguration $getRegistryPropertyValueParameters.Name = 'ProductVersion' $returnObject.ProductVersion = Get-RegistryPropertyValue @getRegistryPropertyValueParameters + if (-not [System.String]::IsNullOrEmpty($returnObject.CurrentVersion)) + { + $reportServerCurrentVersion = [System.Version] $returnObject.CurrentVersion + + # Get values from MSReportServer_Instance + $msReportServerInstance = Get-CimInstance -Namespace ('root\Microsoft\SqlServer\ReportServer\RS_{0}\v{1}' -f $instance.InstanceName, $reportServerCurrentVersion.Major) -ClassName 'MSReportServer_Instance' -ErrorAction 'SilentlyContinue' + + if ($msReportServerInstance) + { + $returnObject.EditionID = $msReportServerInstance.EditionID + $returnObject.EditionName = $msReportServerInstance.EditionName + $returnObject.IsSharePointIntegrated = $msReportServerInstance.IsSharePointIntegrated + $returnObject.InstanceId = $msReportServerInstance.InstanceId + } + } + $reportingServicesInstances += $returnObject } diff --git a/tests/Integration/Commands/Get-SqlDscRSSetupConfiguration.Integration.Tests.ps1 b/tests/Integration/Commands/Get-SqlDscRSSetupConfiguration.Integration.Tests.ps1 index a86f50fa6a..76b8732bc6 100644 --- a/tests/Integration/Commands/Get-SqlDscRSSetupConfiguration.Integration.Tests.ps1 +++ b/tests/Integration/Commands/Get-SqlDscRSSetupConfiguration.Integration.Tests.ps1 @@ -43,6 +43,10 @@ Describe 'Get-SqlDscRSSetupConfiguration' { $result.EnableErrorReporting | Should -Be 1 $result.VirtualRootServer | Should -Be 'ReportServer' $result.ConfigFilePath | Should -Be 'C:\Program Files\SSRS\SSRS\ReportServer\rsreportserver.config' + $result.InstanceId | Should -Be 'SSRS' + $result.EditionID | Should -Be 2176971986 + $result.EditionName | Should -Be 'SQL Server Developer' + $result.IsSharePointIntegrated | Should -BeFalse } } @@ -65,6 +69,10 @@ Describe 'Get-SqlDscRSSetupConfiguration' { $result.EnableErrorReporting | Should -Be 1 $result.VirtualRootServer | Should -Be 'ReportServer' $result.ConfigFilePath | Should -Be 'C:\Program Files\SSRS\SSRS\ReportServer\rsreportserver.config' + $result.InstanceId | Should -Be 'SSRS' + $result.EditionID | Should -Be 2176971986 + $result.EditionName | Should -Be 'SQL Server Developer' + $result.IsSharePointIntegrated | Should -BeFalse } } @@ -87,12 +95,18 @@ Describe 'Get-SqlDscRSSetupConfiguration' { $result.EnableErrorReporting | Should -Be 1 $result.VirtualRootServer | Should -Be 'ReportServer' $result.ConfigFilePath | Should -Be 'C:\Program Files\SSRS\SSRS\ReportServer\rsreportserver.config' + $result.InstanceId | Should -Be 'SSRS' + $result.EditionID | Should -Be 2176971986 + $result.EditionName | Should -Be 'SQL Server Developer' + $result.IsSharePointIntegrated | Should -BeFalse } } Context 'When getting the configuration for Power BI Report Server instance' -Tag @('Integration_PowerBI') { # cSpell: ignore PBIRS rsreportserver It 'Should return the correct configuration for PBIRS instance' { + #Write-Verbose -Message ((reg query "HKLM\SOFTWARE\Microsoft\Microsoft SQL Server" /s) | Out-String) -Verbose + # Get the PBIRS configuration $result = Get-SqlDscRSSetupConfiguration -InstanceName 'PBIRS' @@ -108,6 +122,10 @@ Describe 'Get-SqlDscRSSetupConfiguration' { $result.EnableErrorReporting | Should -Be 1 $result.VirtualRootServer | Should -Be 'ReportServer' $result.ConfigFilePath | Should -Be 'C:\Program Files\PBIRS\PBIRS\ReportServer\rsreportserver.config' + $result.InstanceId | Should -Be 'PBIRS' + $result.EditionID | Should -Be 2017617798 + $result.EditionName | Should -Be 'Power BI Report Server - Developer' + $result.IsSharePointIntegrated | Should -BeFalse } } diff --git a/tests/Integration/Commands/Install-SqlDscBIReportServer.Integration.Tests.ps1 b/tests/Integration/Commands/Install-SqlDscBIReportServer.Integration.Tests.ps1 index 06be82283f..78431dfea8 100644 --- a/tests/Integration/Commands/Install-SqlDscBIReportServer.Integration.Tests.ps1 +++ b/tests/Integration/Commands/Install-SqlDscBIReportServer.Integration.Tests.ps1 @@ -42,7 +42,7 @@ Describe 'Install-SqlDscBIReportServer' -Tag @('Integration_PowerBI') { AcceptLicensingTerms = $true MediaPath = $powerBIReportServerExecutable InstallFolder = 'C:\Program Files\PBIRS' - Edition = 'Evaluation' + Edition = 'Developer' LogPath = Join-Path -Path $script:temporaryFolder -ChildPath 'PowerBIReportServer_Install.log' SuppressRestart = $true Verbose = $true diff --git a/tests/Unit/Public/Get-SqlDscRSSetupConfiguration.Tests.ps1 b/tests/Unit/Public/Get-SqlDscRSSetupConfiguration.Tests.ps1 index c82e7d380b..71b3b9ac05 100644 --- a/tests/Unit/Public/Get-SqlDscRSSetupConfiguration.Tests.ps1 +++ b/tests/Unit/Public/Get-SqlDscRSSetupConfiguration.Tests.ps1 @@ -47,6 +47,38 @@ AfterAll { } Describe 'Get-SqlDscRSSetupConfiguration' { + BeforeAll { + InModuleScope -ScriptBlock { + function script:Get-CimInstance + { + param + ( + [System.String] + $ClassName, + + [System.String] + $Namespace + ) + + $PSCmdlet.ThrowTerminatingError( + [System.Management.Automation.ErrorRecord]::new( + 'StubNotImplemented', + 'StubCalledError', + [System.Management.Automation.ErrorCategory]::InvalidOperation, + $MyInvocation.MyCommand + ) + ) + + } + } + } + + AfterAll { + InModuleScope -ScriptBlock { + Remove-Item -Path 'function:script:Get-CimInstance' -Force + } + } + Context 'When getting all Reporting Services instances' { # cSpell: ignore PBIRS rsreportserver BeforeAll { @@ -166,6 +198,15 @@ Describe 'Get-SqlDscRSSetupConfiguration' { } -MockWith { return $mockProductVersion } + + Mock -CommandName Get-CimInstance -MockWith { + return [PSCustomObject] @{ + EditionID = 2176971986 + EditionName = 'SQL Server Developer' + IsSharePointIntegrated = $false + InstanceId = 'SSRS' + } + } } It 'Should return all Reporting Services instances' { @@ -184,6 +225,10 @@ Describe 'Get-SqlDscRSSetupConfiguration' { $result[0].EnableErrorReporting | Should -Be $mockEnableErrorReporting $result[0].CurrentVersion | Should -Be $mockCurrentVersion $result[0].ProductVersion | Should -Be $mockProductVersion + $result[0].EditionID | Should -Be 2176971986 + $result[0].EditionName | Should -Be 'SQL Server Developer' + $result[0].IsSharePointIntegrated | Should -BeFalse + $result[0].InstanceId | Should -Be 'SSRS' $result[1].InstanceName | Should -Be $mockPBIRSInstance.InstanceName $result[1].InstallFolder | Should -Be $mockInstallFolder @@ -195,6 +240,10 @@ Describe 'Get-SqlDscRSSetupConfiguration' { $result[1].EnableErrorReporting | Should -Be $mockEnableErrorReporting $result[1].CurrentVersion | Should -Be $mockCurrentVersion $result[1].ProductVersion | Should -Be $mockProductVersion + $result[0].EditionID | Should -Be 2176971986 + $result[0].EditionName | Should -Be 'SQL Server Developer' + $result[0].IsSharePointIntegrated | Should -BeFalse + $result[0].InstanceId | Should -Be 'SSRS' Should -Invoke -CommandName Get-SqlDscInstalledInstance -ParameterFilter { $ServiceType -eq 'ReportingServices' -and @@ -211,17 +260,32 @@ Describe 'Get-SqlDscRSSetupConfiguration' { $mockSSRSInstance = @{ InstanceName = 'SSRS' ServiceName = 'ReportServer' + CurrentVersion = '15.0.1.0' } # Mock registry values - $mockInstallFolder = 'C:\Program Files\Microsoft SQL Server Reporting Services' + #$mockInstallFolder = 'C:\Program Files\Microsoft SQL Server Reporting Services' Mock -CommandName Get-SqlDscInstalledInstance -MockWith { return @($mockSSRSInstance) } - Mock -CommandName Get-RegistryPropertyValue -MockWith { - return $mockInstallFolder + Mock -CommandName Get-RegistryPropertyValue + Mock -CommandName Get-RegistryPropertyValue -ParameterFilter { + $Path -eq 'HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\SSRS\MSSQLServer\CurrentVersion' -and + $Name -eq 'CurrentVersion' + } -MockWith { + return '15.0.1.0' + } + + Mock -CommandName Get-CimInstance -MockWith { + return [PSCustomObject] @{ + EditionID = 2176971986 + EditionName = 'SQL Server Developer' + IsSharePointIntegrated = $false + Version = '15.0.1.0' + InstanceId = 'SSRS' + } } }