From d41cb31d55711a5fc40c99a209aafd949c2422b6 Mon Sep 17 00:00:00 2001 From: Marko Bozikovic Date: Thu, 25 Apr 2019 12:17:13 +0200 Subject: [PATCH] [#1331] Reporting Services are restarted on settings change --- CHANGELOG.md | 2 ++ DSCResources/MSFT_SqlRS/MSFT_SqlRS.psm1 | 27 ++++++++++++++++--- DSCResources/MSFT_SqlRS/MSFT_SqlRS.schema.mof | 1 + README.md | 3 +++ 4 files changed, 30 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d43701bc85..63c797f010 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/DSCResources/MSFT_SqlRS/MSFT_SqlRS.psm1 b/DSCResources/MSFT_SqlRS/MSFT_SqlRS.psm1 index 2f96ed6d26..95c894c672 100644 --- a/DSCResources/MSFT_SqlRS/MSFT_SqlRS.psm1 +++ b/DSCResources/MSFT_SqlRS/MSFT_SqlRS.psm1 @@ -224,7 +224,11 @@ function Set-TargetResource [Parameter()] [System.Boolean] - $UseSsl + $UseSsl, + + [Parameter()] + [System.Boolean] + $SuppressRestart ) $reportingServicesData = Get-ReportingServicesData -InstanceName $InstanceName @@ -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 ) { @@ -454,8 +462,6 @@ function Set-TargetResource Invoke-RsCimMethod @invokeRsCimMethodParameters } - - Restart-ReportingServicesService -SQLInstanceName $InstanceName -WaitTime 30 } else { @@ -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 @@ -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 @@ -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 @@ -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 @@ -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' @@ -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) ) diff --git a/DSCResources/MSFT_SqlRS/MSFT_SqlRS.schema.mof b/DSCResources/MSFT_SqlRS/MSFT_SqlRS.schema.mof index 2c0a1669ee..6875b236db 100644 --- a/DSCResources/MSFT_SqlRS/MSFT_SqlRS.schema.mof +++ b/DSCResources/MSFT_SqlRS/MSFT_SqlRS.schema.mof @@ -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; }; diff --git a/README.md b/README.md index 30dfb52cf1..2a3f615ddc 100644 --- a/README.md +++ b/README.md @@ -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