Skip to content

Commit

Permalink
[dsccommunity#1331] Reporting Services are restarted on settings change
Browse files Browse the repository at this point in the history
  • Loading branch information
bozho committed Apr 25, 2019
1 parent cce75a3 commit d41cb31
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
- Concatenated Robocopy localization strings ([issue #694](https://github.com/PowerShell/SqlServerDsc/issues/694)).
- Changes to SqlWaitForAG
- Added en-US localization ([issue #625](https://github.com/PowerShell/SqlServerDsc/issues/625)).
- Changes to SqlRS
- Reporting Services are restarted after changing settings, unless `$SuppressRestart` parameter is set ([issue #1331](https://github.com/PowerShell/SqlServerDsc/issues/1331)). `$SuppressRestart` will also prevent Reporting Services restart after initialization.

## 12.4.0.0

Expand Down
27 changes: 24 additions & 3 deletions DSCResources/MSFT_SqlRS/MSFT_SqlRS.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,11 @@ function Set-TargetResource

[Parameter()]
[System.Boolean]
$UseSsl
$UseSsl,

[Parameter()]
[System.Boolean]
$SuppressRestart
)

$reportingServicesData = Get-ReportingServicesData -InstanceName $InstanceName
Expand Down Expand Up @@ -278,11 +282,15 @@ function Set-TargetResource
}

$language = $wmiOperatingSystem.OSLanguage
$restartReportingService = $false

if ( -not $reportingServicesData.Configuration.IsInitialized )
{
New-VerboseMessage -Message "Initializing Reporting Services on $DatabaseServerName\$DatabaseInstanceName."

# We will restart Reporting Services after initialization (unless SuppressRestart is set)
$restartReportingService = $true

# If no Report Server reserved URLs have been specified, use the default one.
if ( $null -eq $ReportServerReservedUrl )
{
Expand Down Expand Up @@ -454,8 +462,6 @@ function Set-TargetResource

Invoke-RsCimMethod @invokeRsCimMethodParameters
}

Restart-ReportingServicesService -SQLInstanceName $InstanceName -WaitTime 30
}
else
{
Expand Down Expand Up @@ -490,6 +496,8 @@ function Set-TargetResource
{
New-VerboseMessage -Message "Setting report server virtual directory on $DatabaseServerName\$DatabaseInstanceName to $ReportServerVirtualDirectory."

$restartReportingService = $true

$currentConfig.ReportServerReservedUrl | ForEach-Object -Process {
$invokeRsCimMethodParameters = @{
CimInstance = $reportingServicesData.Configuration
Expand Down Expand Up @@ -535,6 +543,8 @@ function Set-TargetResource
{
New-VerboseMessage -Message "Setting reports virtual directory on $DatabaseServerName\$DatabaseInstanceName to $ReportServerVirtualDirectory."

$restartReportingService = $true

$currentConfig.ReportsReservedUrl | ForEach-Object -Process {
$invokeRsCimMethodParameters = @{
CimInstance = $reportingServicesData.Configuration
Expand Down Expand Up @@ -583,6 +593,8 @@ function Set-TargetResource

if ( ($null -ne $ReportServerReservedUrl) -and ($null -ne (Compare-Object @compareParameters)) )
{
$restartReportingService = $true

$currentConfig.ReportServerReservedUrl | ForEach-Object -Process {
$invokeRsCimMethodParameters = @{
CimInstance = $reportingServicesData.Configuration
Expand Down Expand Up @@ -620,6 +632,8 @@ function Set-TargetResource

if ( ($null -ne $ReportsReservedUrl) -and ($null -ne (Compare-Object @compareParameters)) )
{
$restartReportingService = $true

$currentConfig.ReportsReservedUrl | ForEach-Object -Process {
$invokeRsCimMethodParameters = @{
CimInstance = $reportingServicesData.Configuration
Expand Down Expand Up @@ -655,6 +669,8 @@ function Set-TargetResource
{
New-VerboseMessage -Message "Changing value for using SSL to '$UseSsl'."

$restartReportingService = $true

$invokeRsCimMethodParameters = @{
CimInstance = $reportingServicesData.Configuration
MethodName = 'SetSecureConnectionLevel'
Expand All @@ -666,6 +682,11 @@ function Set-TargetResource
Invoke-RsCimMethod @invokeRsCimMethodParameters
}
}

if ( $restartReportingService -and (-not $SuppressRestart) )
{
Restart-ReportingServicesService -SQLInstanceName $InstanceName -WaitTime 30
}
}

if ( -not (Test-TargetResource @PSBoundParameters) )
Expand Down
1 change: 1 addition & 0 deletions DSCResources/MSFT_SqlRS/MSFT_SqlRS.schema.mof
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ class MSFT_SqlRS : OMI_BaseResource
[Write, Description("Report Server URL reservations. Optional. If not specified, 'http://+:80' URL reservation will be used.")] String ReportServerReservedUrl[];
[Write, Description("Report Manager/Report Web App URL reservations. Optional. If not specified, 'http://+:80' URL reservation will be used.")] String ReportsReservedUrl[];
[Write, Description("If connections to the Reporting Services must use SSL. If this parameter is not assigned a value, the default is that Reporting Services does not use SSL.")] Boolean UseSsl;
[Write, Description("Reporting Services need to be restarted after initialization or settings change. If this parameter is set to $true, Reporting Services will not be restarted.")] Boolean SuppressRestart;
[Read, Description("Is the Reporting Services instance initialized.")] Boolean IsInitialized;
};
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,9 @@ Initializes and configures SQL Reporting Services server.
* **`[Boolean]` UseSsl** _(Write)_: If connections to the Reporting Services must
use SSL. If this parameter is not assigned a value, the default is that Reporting
Services does not use SSL.
* **`[Boolean]` SupressRestart** _(Write)_: Reporting Services need to be restarted
after initialization or settings change. If this parameter is set to $true,
Reporting Services will not be restarted.

#### Read-Only Properties from Get-TargetResource

Expand Down

0 comments on commit d41cb31

Please sign in to comment.