Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
45 changes: 35 additions & 10 deletions source/Public/Get-SqlDscRSSetupConfiguration.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
}

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

Expand All @@ -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
}
}

Expand All @@ -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'

Expand All @@ -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
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
70 changes: 67 additions & 3 deletions tests/Unit/Public/Get-SqlDscRSSetupConfiguration.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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' {
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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'
}
}
}

Expand Down