From 0e1a7cab43b238fc5c42d17bf5cb0578c3845cf3 Mon Sep 17 00:00:00 2001 From: Marko Bozikovic Date: Fri, 22 Sep 2017 19:59:33 +0100 Subject: [PATCH] xSQLServerRSConfig: Virtual directories and URL reservations (#638) - Changes to xSQLServerRSConfig - Added support for configuring URL reservations and virtual directory names ([issue #570](https://github.com/PowerShell/xSQLServer/issues/570)) --- CHANGELOG.md | 2 + .../MSFT_xSQLServerRSConfig.psm1 | 459 ++++++++++++++---- .../MSFT_xSQLServerRSConfig.schema.mof | 4 + README.md | 11 +- Tests/Unit/MSFT_xSQLServerRSConfig.Tests.ps1 | 379 ++++++++++++--- 5 files changed, 695 insertions(+), 160 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 28cdc9da1..5c98e8529 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -107,6 +107,8 @@ initializing ([issue #592](https://github.com/PowerShell/xSQLServer/issues/592)). This will enable the Reports site to work. - Added integration test ([issue #753](https://github.com/PowerShell/xSQLServer/issues/753)). + - Added support for configuring URL reservations and virtual directory names + ([issue #570](https://github.com/PowerShell/xSQLServer/issues/570)) ## 8.1.0.0 diff --git a/DSCResources/MSFT_xSQLServerRSConfig/MSFT_xSQLServerRSConfig.psm1 b/DSCResources/MSFT_xSQLServerRSConfig/MSFT_xSQLServerRSConfig.psm1 index d0566ca7d..10e37433e 100644 --- a/DSCResources/MSFT_xSQLServerRSConfig/MSFT_xSQLServerRSConfig.psm1 +++ b/DSCResources/MSFT_xSQLServerRSConfig/MSFT_xSQLServerRSConfig.psm1 @@ -4,16 +4,16 @@ Import-Module -Name (Join-Path -Path (Split-Path (Split-Path $PSScriptRoot -Pare <# .SYNOPSIS - Gets the SQL Reporting Services initialization status. + Gets the SQL Reporting Services initialization status. .PARAMETER InstanceName - Name of the SQL Server Reporting Services instance to be configured. + Name of the SQL Server Reporting Services instance to be configured. .PARAMETER RSSQLServer - Name of the SQL Server to host the Reporting Service database. + Name of the SQL Server to host the Reporting Service database. .PARAMETER RSSQLInstanceName - Name of the SQL Server instance to host the Reporting Service database. + Name of the SQL Server instance to host the Reporting Service database. #> function Get-TargetResource { @@ -34,31 +34,47 @@ function Get-TargetResource $RSSQLInstanceName ) - $instanceNamesRegistryKey = 'HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\Instance Names\RS' + $reportingServicesData = Get-ReportingServicesData -InstanceName $InstanceName - if ( Get-ItemProperty -Path $instanceNamesRegistryKey -Name $InstanceName -ErrorAction SilentlyContinue ) + if ( $null -ne $reportingServicesData.Configuration ) { - $instanceId = (Get-ItemProperty -Path $instanceNamesRegistryKey -Name $InstanceName).$InstanceName - $sqlVersion = ((Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\$instanceId\Setup" -Name 'Version').Version).Split('.')[0] - - $reportingServicesConfiguration = Get-WmiObject -Class MSReportServer_ConfigurationSetting -Namespace "root\Microsoft\SQLServer\ReportServer\RS_$InstanceName\v$sqlVersion\Admin" - $reportingServicesConfiguration = $reportingServicesConfiguration | Where-Object -FilterScript { - $_.InstanceName -eq $InstanceName - } - - if ( $reportingServicesConfiguration.DatabaseServerName.Contains('\') ) + if ( $reportingServicesData.Configuration.DatabaseServerName.Contains('\') ) { - $RSSQLServer = $reportingServicesConfiguration.DatabaseServerName.Split('\')[0] - $RSSQLInstanceName = $reportingServicesConfiguration.DatabaseServerName.Split('\')[1] + $RSSQLServer = $reportingServicesData.Configuration.DatabaseServerName.Split('\')[0] + $RSSQLInstanceName = $reportingServicesData.Configuration.DatabaseServerName.Split('\')[1] } else { - $RSSQLServer = $reportingServicesConfiguration.DatabaseServerName + $RSSQLServer = $reportingServicesData.Configuration.DatabaseServerName $RSSQLInstanceName = 'MSSQLSERVER' } - $isInitialized = $reportingServicesConfiguration.IsInitialized - if (-not $isInitialized) + $isInitialized = $reportingServicesData.Configuration.IsInitialized + + if ( $isInitialized ) + { + $reportServerVirtualDirectory = $reportingServicesData.Configuration.VirtualDirectoryReportServer + $reportsVirtualDirectory = $reportingServicesData.Configuration.VirtualDirectoryReportManager + + $reservedUrls = $reportingServicesData.Configuration.ListReservedUrls() + + $reportServerReservedUrl = @() + $reportsReservedUrl = @() + + for ( $i = 0; $i -lt $reservedUrls.Application.Count; ++$i ) + { + if ( $reservedUrls.Application[$i] -eq 'ReportServerWebService' ) + { + $reportServerReservedUrl += $reservedUrls.UrlString[$i] + } + + if ( $reservedUrls.Application[$i] -eq $reportingServicesData.ReportsApplicationName ) + { + $reportsReservedUrl += $reservedUrls.UrlString[$i] + } + } + } + else { <# Make sure the value returned is false, if the value returned was @@ -72,28 +88,42 @@ function Get-TargetResource throw New-TerminatingError -ErrorType SSRSNotFound -FormatArgs @($InstanceName) -ErrorCategory ObjectNotFound } - $returnValue = @{ - InstanceName = $InstanceName - RSSQLServer = $RSSQLServer - RSSQLInstanceName = $RSSQLInstanceName - IsInitialized = $isInitialized + return @{ + InstanceName = $InstanceName + RSSQLServer = $RSSQLServer + RSSQLInstanceName = $RSSQLInstanceName + ReportServerVirtualDirectory = $reportServerVirtualDirectory + ReportsVirtualDirectory = $reportsVirtualDirectory + ReportServerReservedUrl = $reportServerReservedUrl + ReportsReservedUrl = $reportsReservedUrl + IsInitialized = $isInitialized } - - $returnValue } <# .SYNOPSIS - Initializes SQL Reporting Services. + Initializes SQL Reporting Services. .PARAMETER InstanceName - Name of the SQL Server Reporting Services instance to be configured. + Name of the SQL Server Reporting Services instance to be configured. .PARAMETER RSSQLServer - Name of the SQL Server to host the Reporting Service database. + Name of the SQL Server to host the Reporting Service database. .PARAMETER RSSQLInstanceName - Name of the SQL Server instance to host the Reporting Service database. + Name of the SQL Server instance to host the Reporting Service database. + + .PARAMETER ReportServerVirtualDirectory + Report Server Web Service virtual directory. Optional. + + .PARAMETER ReportsVirtualDirectory + Report Manager/Report Web App virtual directory name. Optional. + + .PARAMETER ReportServerReservedUrl + Report Server URL reservations. Optional. If not specified, 'http://+:80' URL reservation will be used. + + .PARAMETER ReportsReservedUrl + Report Manager/Report Web App URL reservations. Optional. If not specified, 'http://+:80' URL reservation will be used. #> function Set-TargetResource { @@ -110,35 +140,57 @@ function Set-TargetResource [Parameter(Mandatory = $true)] [System.String] - $RSSQLInstanceName - ) + $RSSQLInstanceName, - $instanceNamesRegistryKey = 'HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\Instance Names\RS' + [Parameter()] + [System.String] + $ReportServerVirtualDirectory, - if ( Get-ItemProperty -Path $instanceNamesRegistryKey -Name $InstanceName -ErrorAction SilentlyContinue ) - { - <# - Import-SQLPSModule cmdlet will import SQLPS (SQL 2012/14) or SqlServer module (SQL 2016), - and if importing SQLPS, change directory back to the original one, since SQLPS changes the - current directory to SQLSERVER:\ on import. - #> - Import-SQLPSModule + [Parameter()] + [System.String] + $ReportsVirtualDirectory, - $instanceId = (Get-ItemProperty -Path $instanceNamesRegistryKey -Name $InstanceName).$InstanceName - $sqlVersion = [System.Int32]((Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\$instanceId\Setup" -Name 'Version').Version).Split('.')[0] + [Parameter()] + [System.String[]] + $ReportServerReservedUrl, + + [Parameter()] + [System.String[]] + $ReportsReservedUrl + ) + $reportingServicesData = Get-ReportingServicesData -InstanceName $InstanceName + + if ( $null -ne $reportingServicesData.Configuration ) + { if ( $InstanceName -eq 'MSSQLSERVER' ) { + if ( [string]::IsNullOrEmpty($ReportServerVirtualDirectory) ) + { + $ReportServerVirtualDirectory = 'ReportServer' + } + + if ( [string]::IsNullOrEmpty($ReportsVirtualDirectory) ) + { + $ReportsVirtualDirectory = 'Reports' + } + $reportingServicesServiceName = 'ReportServer' - $reportServerVirtualDirectoryName = 'ReportServer' - $reportsVirtualDirectoryName = 'Reports' $reportingServicesDatabaseName = 'ReportServer' } else { + if ( [string]::IsNullOrEmpty($ReportServerVirtualDirectory) ) + { + $ReportServerVirtualDirectory = "ReportServer_$InstanceName" + } + + if ( [string]::IsNullOrEmpty($ReportsVirtualDirectory) ) + { + $ReportsVirtualDirectory = "Reports_$InstanceName" + } + $reportingServicesServiceName = "ReportServer`$$InstanceName" - $reportServerVirtualDirectoryName = "ReportServer_$InstanceName" - $reportsVirtualDirectoryName = "Reports_$InstanceName" $reportingServicesDatabaseName = "ReportServer`$$InstanceName" } @@ -151,52 +203,168 @@ function Set-TargetResource $reportingServicesConnection = "$RSSQLServer\$RSSQLInstanceName" } - $language = (Get-WMIObject -Class Win32_OperatingSystem -Namespace root/cimv2 -ErrorAction SilentlyContinue).OSLanguage - $reportingServicesConfiguration = Get-WmiObject -Class MSReportServer_ConfigurationSetting -Namespace "root\Microsoft\SQLServer\ReportServer\RS_$InstanceName\v$sqlVersion\Admin" - $reportingServicesConfiguration = $reportingServicesConfiguration | Where-Object -FilterScript { - $_.InstanceName -eq $InstanceName + $wmiOperatingSystem = Get-WMIObject -Class Win32_OperatingSystem -Namespace 'root/cimv2' -ErrorAction SilentlyContinue + if ( $null -eq $wmiOperatingSystem ) + { + throw 'Unable to find WMI object Win32_OperatingSystem.' } - if ( $reportingServicesConfiguration.VirtualDirectoryReportServer -ne $reportServerVirtualDirectoryName ) + $language = $wmiOperatingSystem.OSLanguage + + if ( -not $reportingServicesData.Configuration.IsInitialized ) { - $null = $reportingServicesConfiguration.SetVirtualDirectory('ReportServerWebService', $reportServerVirtualDirectoryName, $language) - $null = $reportingServicesConfiguration.ReserveURL('ReportServerWebService', 'http://+:80', $language) - } + New-VerboseMessage -Message "Initializing Reporting Services on $RSSQLServer\$RSSQLInstanceName." + + # If no Report Server reserved URLs have been specified, use the default one. + if ( $null -eq $ReportServerReservedUrl ) + { + $ReportServerReservedUrl = @('http://+:80') + } + + # If no Report Manager/Report Web App reserved URLs have been specified, use the default one. + if ( $null -eq $ReportsReservedUrl ) + { + $ReportsReservedUrl = @('http://+:80') + } - if ( $reportingServicesConfiguration.VirtualDirectoryReportManager -ne $reportsVirtualDirectoryName ) + if ( $reportingServicesData.Configuration.VirtualDirectoryReportServer -ne $ReportServerVirtualDirectory ) + { + New-VerboseMessage -Message "Setting report server virtual directory on $RSSQLServer\$RSSQLInstanceName to $ReportServerVirtualDirectory." + $null = $reportingServicesData.Configuration.SetVirtualDirectory('ReportServerWebService', $ReportServerVirtualDirectory, $language) + $ReportServerReservedUrl | ForEach-Object -Process { + New-VerboseMessage -Message "Adding report server URL reservation on $RSSQLServer\$RSSQLInstanceName`: $_." + $null = $reportingServicesData.Configuration.ReserveURL('ReportServerWebService', $_, $language) + } + } + + if ( $reportingServicesData.Configuration.VirtualDirectoryReportManager -ne $ReportsVirtualDirectory ) + { + New-VerboseMessage -Message "Setting reports virtual directory on $RSSQLServer\$RSSQLInstanceName to $ReportServerVirtualDirectory." + $null = $reportingServicesData.Configuration.SetVirtualDirectory($reportingServicesData.ReportsApplicationName, $ReportsVirtualDirectory, $language) + $ReportsReservedUrl | ForEach-Object -Process { + New-VerboseMessage -Message "Adding reports URL reservation on $RSSQLServer\$RSSQLInstanceName`: $_." + $null = $reportingServicesData.Configuration.ReserveURL($reportingServicesData.ReportsApplicationName, $_, $language) + } + } + + $reportingServicesDatabaseScript = $reportingServicesData.Configuration.GenerateDatabaseCreationScript($reportingServicesDatabaseName, $language, $false) + + # Determine RS service account + $reportingServicesServiceAccountUserName = (Get-WmiObject -Class Win32_Service | Where-Object -FilterScript { + $_.Name -eq $reportingServicesServiceName + }).StartName + $reportingServicesDatabaseRightsScript = $reportingServicesData.Configuration.GenerateDatabaseRightsScript($reportingServicesServiceAccountUserName, $reportingServicesDatabaseName, $false, $true) + + <# + Import-SQLPSModule cmdlet will import SQLPS (SQL 2012/14) or SqlServer module (SQL 2016), + and if importing SQLPS, change directory back to the original one, since SQLPS changes the + current directory to SQLSERVER:\ on import. + #> + Import-SQLPSModule + Invoke-Sqlcmd -ServerInstance $reportingServicesConnection -Query $reportingServicesDatabaseScript.Script + Invoke-Sqlcmd -ServerInstance $reportingServicesConnection -Query $reportingServicesDatabaseRightsScript.Script + + $null = $reportingServicesData.Configuration.SetDatabaseConnection($reportingServicesConnection, $reportingServicesDatabaseName, 2, '', '') + $null = $reportingServicesData.Configuration.InitializeReportServer($reportingServicesData.Configuration.InstallationID) + + Restart-ReportingServicesService -SQLInstanceName $InstanceName + } + else { + $getTargetResourceParameters = @{ + InstanceName = $InstanceName + RSSQLServer = $RSSQLServer + RSSQLInstanceName = $RSSQLInstanceName + } + + $currentConfig = Get-TargetResource @getTargetResourceParameters + <# - SSRS Web Portal application name changed in SQL Server 2016 - https://docs.microsoft.com/en-us/sql/reporting-services/breaking-changes-in-sql-server-reporting-services-in-sql-server-2016 + SQL Server Reporting Services virtual directories (both + Report Server and Report Manager/Report Web App) are a + part of SQL Server Reporting Services URL reservations. + + The default SQL Server Reporting Services URL reservations are: + http://+:80/ReportServer/ (for Report Server) + and + http://+:80/Reports/ (for Report Manager/Report Web App) + + You can get them by running 'netsh http show urlacl' from + command line. + + In order to change a virtual directory, we first need to remove + existing URL reservations, change the appropriate virtual directory + setting and re-add URL reservations, which will then contain the + new virtual directory. #> - if ($sqlVersion -ge 13) + + if ( -not [string]::IsNullOrEmpty($ReportServerVirtualDirectory) -and ($ReportServerVirtualDirectory -ne $currentConfig.ReportServerVirtualDirectory) ) { - $virtualDirectoryName = 'ReportServerWebApp' + New-VerboseMessage -Message "Setting report server virtual directory on $RSSQLServer\$RSSQLInstanceName to $ReportServerVirtualDirectory." + + $currentConfig.ReportServerReservedUrl | ForEach-Object -Process { + $null = $reportingServicesData.Configuration.RemoveURL('ReportServerWebService', $_, $language) + } + + $reportingServicesData.Configuration.SetVirtualDirectory('ReportServerWebService', $ReportServerVirtualDirectory, $language) + + $currentConfig.ReportServerReservedUrl | ForEach-Object -Process { + $null = $reportingServicesData.Configuration.ReserveURL('ReportServerWebService', $_, $language) + } } - else + + if ( -not [string]::IsNullOrEmpty($ReportsVirtualDirectory) -and ($ReportsVirtualDirectory -ne $currentConfig.ReportsVirtualDirectory) ) { - $virtualDirectoryName = 'ReportManager' - } + New-VerboseMessage -Message "Setting reports virtual directory on $RSSQLServer\$RSSQLInstanceName to $ReportServerVirtualDirectory." - $null = $reportingServicesConfiguration.SetVirtualDirectory($virtualDirectoryName, $reportsVirtualDirectoryName, $language) - $null = $reportingServicesConfiguration.ReserveURL($virtualDirectoryName, 'http://+:80', $language) - } + $currentConfig.ReportsReservedUrl | ForEach-Object -Process { + $null = $reportingServicesData.Configuration.RemoveURL($reportingServicesData.ReportsApplicationName, $_, $language) + } - $reportingServicesDatabaseScript = $reportingServicesConfiguration.GenerateDatabaseCreationScript($reportingServicesDatabaseName, $language, $false) + $reportingServicesData.Configuration.SetVirtualDirectory($reportingServicesData.ReportsApplicationName, $ReportsVirtualDirectory, $language) - # Determine RS service account - $reportingServicesServiceAccountUserName = (Get-WmiObject -Class Win32_Service | Where-Object {$_.Name -eq $reportingServicesServiceName}).StartName - $reportingServicesDatabaseRightsScript = $reportingServicesConfiguration.GenerateDatabaseRightsScript($reportingServicesServiceAccountUserName, $reportingServicesDatabaseName, $false, $true) + $currentConfig.ReportsReservedUrl | ForEach-Object -Process { + $null = $reportingServicesData.Configuration.ReserveURL($reportingServicesData.ReportsApplicationName, $_, $language) + } + } - Invoke-Sqlcmd -ServerInstance $reportingServicesConnection -Query $reportingServicesDatabaseScript.Script - Invoke-Sqlcmd -ServerInstance $reportingServicesConnection -Query $reportingServicesDatabaseRightsScript.Script - $null = $reportingServicesConfiguration.SetDatabaseConnection($reportingServicesConnection, $reportingServicesDatabaseName, 2, '', '') - $null = $reportingServicesConfiguration.InitializeReportServer($reportingServicesConfiguration.InstallationID) + $compareParameters = @{ + ReferenceObject = $currentConfig.ReportServerReservedUrl + DifferenceObject = $ReportServerReservedUrl + } - Restart-ReportingServicesService -SQLInstanceName $InstanceName + if ( ($null -ne $ReportServerReservedUrl) -and ($null -ne (Compare-Object @compareParameters)) ) + { + $currentConfig.ReportServerReservedUrl | ForEach-Object -Process { + $null = $reportingServicesData.Configuration.RemoveURL('ReportServerWebService', $_, $language) + } + + $ReportServerReservedUrl | ForEach-Object -Process { + New-VerboseMessage -Message "Adding report server URL reservation on $RSSQLServer\$RSSQLInstanceName`: $_." + $null = $reportingServicesData.Configuration.ReserveURL('ReportServerWebService', $_, $language) + } + } + + $compareParameters = @{ + ReferenceObject = $currentConfig.ReportsReservedUrl + DifferenceObject = $ReportsReservedUrl + } + + if ( ($null -ne $ReportsReservedUrl) -and ($null -ne (Compare-Object @compareParameters)) ) + { + $currentConfig.ReportsReservedUrl | ForEach-Object -Process { + $null = $reportingServicesData.Configuration.RemoveURL($reportingServicesData.ReportsApplicationName, $_, $language) + } + + $ReportsReservedUrl | ForEach-Object -Process { + New-VerboseMessage -Message "Adding reports URL reservation on $RSSQLServer\$RSSQLInstanceName`: $_." + $null = $reportingServicesData.Configuration.ReserveURL($reportingServicesData.ReportsApplicationName, $_, $language) + } + } + } } - if ( !(Test-TargetResource @PSBoundParameters) ) + if ( -not (Test-TargetResource @PSBoundParameters) ) { throw New-TerminatingError -ErrorType TestFailedAfterSet -ErrorCategory InvalidResult } @@ -204,16 +372,28 @@ function Set-TargetResource <# .SYNOPSIS - Tests the SQL Reporting Services initialization status. + Tests the SQL Reporting Services initialization status. .PARAMETER InstanceName - Name of the SQL Server Reporting Services instance to be configured. + Name of the SQL Server Reporting Services instance to be configured. .PARAMETER RSSQLServer - Name of the SQL Server to host the Reporting Service database. + Name of the SQL Server to host the Reporting Service database. .PARAMETER RSSQLInstanceName - Name of the SQL Server instance to host the Reporting Service database. + Name of the SQL Server instance to host the Reporting Service database. + + .PARAMETER ReportServerVirtualDirectory + Report Server Web Service virtual directory. Optional. + + .PARAMETER ReportsVirtualDirectory + Report Manager/Report Web App virtual directory name. Optional. + + .PARAMETER ReportServerReservedUrl + Report Server URL reservations. Optional. If not specified, 'http://+:80' URL reservation will be used. + + .PARAMETER ReportsReservedUrl + Report Manager/Report Web App URL reservations. Optional. If not specified, 'http://+:80' URL reservation will be used. #> function Test-TargetResource { @@ -231,12 +411,125 @@ function Test-TargetResource [Parameter(Mandatory = $true)] [System.String] - $RSSQLInstanceName + $RSSQLInstanceName, + + [Parameter()] + [System.String] + $ReportServerVirtualDirectory, + + [Parameter()] + [System.String] + $ReportsVirtualDirectory, + + [Parameter()] + [System.String[]] + $ReportServerReservedUrl, + + [Parameter()] + [System.String[]] + $ReportsReservedUrl ) - $result = (Get-TargetResource @PSBoundParameters).IsInitialized + $result = $true + + $getTargetResourceParameters = @{ + InstanceName = $InstanceName + RSSQLServer = $RSSQLServer + RSSQLInstanceName = $RSSQLInstanceName + } + + $currentConfig = Get-TargetResource @getTargetResourceParameters + + if ( -not $currentConfig.IsInitialized ) + { + New-VerboseMessage -Message "Reporting services $RSSQLServer\$RSSQLInstanceName are not initialized." + $result = $false + } + + if ( -not [string]::IsNullOrEmpty($ReportServerVirtualDirectory) -and ($ReportServerVirtualDirectory -ne $currentConfig.ReportServerVirtualDirectory) ) + { + New-VerboseMessage -Message "Report server virtual directory on $RSSQLServer\$RSSQLInstanceName is $($currentConfig.ReportServerVirtualDir), should be $ReportServerVirtualDirectory." + $result = $false + } + + if ( -not [string]::IsNullOrEmpty($ReportsVirtualDirectory) -and ($ReportsVirtualDirectory -ne $currentConfig.ReportsVirtualDirectory) ) + { + New-VerboseMessage -Message "Reports virtual directory on $RSSQLServer\$RSSQLInstanceName is $($currentConfig.ReportsVirtualDir), should be $ReportsVirtualDirectory." + $result = $false + } + + $compareParameters = @{ + ReferenceObject = $currentConfig.ReportServerReservedUrl + DifferenceObject = $ReportServerReservedUrl + } + + if ( ($null -ne $ReportServerReservedUrl) -and ($null -ne (Compare-Object @compareParameters)) ) + { + New-VerboseMessage -Message "Report server reserved URLs on $RSSQLServer\$RSSQLInstanceName are $($currentConfig.ReportServerReservedUrl -join ', '), should be $($ReportServerReservedUrl -join ', ')." + $result = $false + } + + $compareParameters = @{ + ReferenceObject = $currentConfig.ReportsReservedUrl + DifferenceObject = $ReportsReservedUrl + } + + if ( ($null -ne $ReportsReservedUrl) -and ($null -ne (Compare-Object @compareParameters)) ) + { + New-VerboseMessage -Message "Reports reserved URLs on $RSSQLServer\$RSSQLInstanceName are $($currentConfig.ReportsReservedUrl -join ', ')), should be $($ReportsReservedUrl -join ', ')." + $result = $false + } $result } +<# + .SYNOPSIS + Returns SQL Reporting Services data: configuration object used to initialize and configure + SQL Reporting Services and the name of the Reports Web application name (changed in SQL 2016) + + .PARAMETER InstanceName + Name of the SQL Server Reporting Services instance for which the data is being retrieved. +#> +function Get-ReportingServicesData +{ + [CmdletBinding()] + [OutputType([System.Collections.Hashtable])] + param + ( + [Parameter(Mandatory = $true)] + [System.String] + $InstanceName + ) + + $instanceNamesRegistryKey = 'HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\Instance Names\RS' + + if ( Get-ItemProperty -Path $instanceNamesRegistryKey -Name $InstanceName -ErrorAction SilentlyContinue ) + { + $instanceId = (Get-ItemProperty -Path $instanceNamesRegistryKey -Name $InstanceName).$InstanceName + $sqlVersion = [System.Int32]((Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\$instanceId\Setup" -Name 'Version').Version).Split('.')[0] + $reportingServicesConfiguration = Get-WmiObject -Class MSReportServer_ConfigurationSetting -Namespace "root\Microsoft\SQLServer\ReportServer\RS_$InstanceName\v$sqlVersion\Admin" + $reportingServicesConfiguration = $reportingServicesConfiguration | Where-Object -FilterScript { + $_.InstanceName -eq $InstanceName + } + <# + SSRS Web Portal application name changed in SQL Server 2016 + https://docs.microsoft.com/en-us/sql/reporting-services/breaking-changes-in-sql-server-reporting-services-in-sql-server-2016 + #> + if ( $sqlVersion -ge 13 ) + { + $reportsApplicationName = 'ReportServerWebApp' + } + else + { + $reportsApplicationName = 'ReportManager' + } + } + + @{ + Configuration = $reportingServicesConfiguration + ReportsApplicationName = $reportsApplicationName + } +} + Export-ModuleMember -Function *-TargetResource diff --git a/DSCResources/MSFT_xSQLServerRSConfig/MSFT_xSQLServerRSConfig.schema.mof b/DSCResources/MSFT_xSQLServerRSConfig/MSFT_xSQLServerRSConfig.schema.mof index 06674454c..ff03fb317 100644 --- a/DSCResources/MSFT_xSQLServerRSConfig/MSFT_xSQLServerRSConfig.schema.mof +++ b/DSCResources/MSFT_xSQLServerRSConfig/MSFT_xSQLServerRSConfig.schema.mof @@ -4,5 +4,9 @@ class MSFT_xSQLServerRSConfig : OMI_BaseResource [Key, Description("Name of the SQL Server Reporting Services instance to be configured.")] String InstanceName; [Required, Description("Name of the SQL Server to host the Reporting Service database.")] String RSSQLServer; [Required, Description("Name of the SQL Server instance to host the Reporting Service database.")] String RSSQLInstanceName; + [Write, Description("Report Server Web Service virtual directory. Optional.")] String ReportServerVirtualDirectory; + [Write, Description("Report Manager/Report Web App virtual directory name. Optional.")] String ReportsVirtualDirectory; + [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[]; [Read, Description("Is the Reporting Services instance initialized.")] Boolean IsInitialized; }; diff --git a/README.md b/README.md index b3d33461a..30accd12d 100644 --- a/README.md +++ b/README.md @@ -1103,7 +1103,7 @@ server roles, please read the below articles. ### xSQLServerRSConfig -No description. +Initializes and configures SQL Reporting Services server. #### Requirements @@ -1121,6 +1121,15 @@ No description. Reporting Service database. * **`[String]` RSSQLInstanceName** _(Required)_: Name of the SQL Server instance to host the Reporting Service database. +* **`[String]` ReportServerVirtualDir** _(Write)_: Report Server Web Service virtual + directory. Optional. +* **`[String]` ReportsVirtualDir** _(Write)_: Report Manager/Report Web App virtual + directory name. Optional. +* **`[String[]]` ReportServerReservedUrl** _(Write)_: Report Server URL reservations. + Optional. If not specified, 'http://+:80' URL reservation will be used. +* **`[String[]]` ReportsReservedUrl** _(Write)_: Report Manager/Report Web App URL + reservations. Optional. If not specified, 'http://+:80' URL reservation will be + used. #### Read-Only Properties from Get-TargetResource diff --git a/Tests/Unit/MSFT_xSQLServerRSConfig.Tests.ps1 b/Tests/Unit/MSFT_xSQLServerRSConfig.Tests.ps1 index db07c5421..0b2bea4e9 100644 --- a/Tests/Unit/MSFT_xSQLServerRSConfig.Tests.ps1 +++ b/Tests/Unit/MSFT_xSQLServerRSConfig.Tests.ps1 @@ -1,14 +1,14 @@ -$script:DSCModuleName = 'xSQLServer' -$script:DSCResourceName = 'MSFT_xSQLServerRSConfig' +$script:DSCModuleName = 'xSQLServer' +$script:DSCResourceName = 'MSFT_xSQLServerRSConfig' #region HEADER # Unit Test Template Version: 1.2.0 $script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or ` - (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) + (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) ) { - & git @('clone','https://github.com/PowerShell/DscResource.Tests.git',(Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) + & git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\')) } Import-Module -Name (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1') -Force @@ -20,11 +20,13 @@ $TestEnvironment = Initialize-TestEnvironment ` #endregion HEADER -function Invoke-TestSetup { +function Invoke-TestSetup +{ Import-Module -Name (Join-Path -Path (Join-Path -Path (Join-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'Tests') -ChildPath 'Unit') -ChildPath 'Stubs') -ChildPath 'SQLPSStub.psm1') -Global -Force } -function Invoke-TestCleanup { +function Invoke-TestCleanup +{ Restore-TestEnvironment -TestEnvironment $TestEnvironment } @@ -40,10 +42,18 @@ try $mockReportingServicesDatabaseNamedInstanceName = $mockNamedInstanceName $mockReportingServicesDatabaseDefaultInstanceName = $mockDefaultInstanceName + $mockReportsApplicationName = 'ReportServerWebApp' + $mockReportsApplicationNameLegacy = 'ReportManager' + $mockReportServerApplicationName = 'ReportServerWebService' + $mockReportsApplicationUrl = 'http://+:80' + $mockReportServerApplicationUrl = 'http://+:80' + $mockVirtualDirectoryReportManagerName = 'Reports_SQL2016' + $mockVirtualDirectoryReportServerName = 'ReportServer_SQL2016' + $mockGetItemProperty = { return @{ InstanceName = $mockInstanceName - Version = $mockDynamic_SqlBuildVersion + Version = $mockDynamic_SqlBuildVersion } } @@ -54,42 +64,64 @@ try Add-Member -MemberType NoteProperty -Name 'DatabaseServerName' -Value "$mockReportingServicesDatabaseServerName\$mockReportingServicesDatabaseNamedInstanceName" -PassThru | Add-Member -MemberType NoteProperty -Name 'IsInitialized' -Value $mockDynamicIsInitialized -PassThru | Add-Member -MemberType NoteProperty -Name 'InstanceName' -Value $mockNamedInstanceName -PassThru | - Add-Member -MemberType NoteProperty -Name 'VirtualDirectoryReportServer' -Value '' -PassThru | - Add-Member -MemberType NoteProperty -Name 'VirtualDirectoryReportManager' -Value '' -PassThru | + Add-Member -MemberType NoteProperty -Name 'VirtualDirectoryReportServer' -Value $mockVirtualDirectoryReportServerName -PassThru | + Add-Member -MemberType NoteProperty -Name 'VirtualDirectoryReportManager' -Value $mockVirtualDirectoryReportManagerName -PassThru | Add-Member -MemberType ScriptMethod -Name SetVirtualDirectory { - $script:mockIsMethodCalled_SetVirtualDirectory = $true + $script:mockIsMethodCalled_SetVirtualDirectory = $true - return $null - } -PassThru | + return $null + } -PassThru | Add-Member -MemberType ScriptMethod -Name ReserveURL { - $script:mockIsMethodCalled_ReserveURL = $true + $script:mockIsMethodCalled_ReserveURL = $true - return $null - } -PassThru | + return $null + } -PassThru | Add-Member -MemberType ScriptMethod -Name GenerateDatabaseCreationScript { - $script:mockIsMethodCalled_GenerateDatabaseCreationScript = $true + $script:mockIsMethodCalled_GenerateDatabaseCreationScript = $true - return @{ - Script = 'select * from something' - } - } -PassThru | + return @{ + Script = 'select * from something' + } + } -PassThru | Add-Member -MemberType ScriptMethod -Name GenerateDatabaseRightsScript { - $script:mockIsMethodCalled_GenerateDatabaseRightsScript = $true + $script:mockIsMethodCalled_GenerateDatabaseRightsScript = $true - return @{ - Script = 'select * from something' - } - } -PassThru | + return @{ + Script = 'select * from something' + } + } -PassThru | Add-Member -MemberType ScriptMethod -Name SetDatabaseConnection { - $script:mockIsMethodCalled_SetDatabaseConnection = $true + $script:mockIsMethodCalled_SetDatabaseConnection = $true - return $null - } -PassThru | + return $null + } -PassThru | Add-Member -MemberType ScriptMethod -Name InitializeReportServer { - $script:mockIsMethodCalled_InitializeReportServer = $true - - return $null + $script:mockIsMethodCalled_InitializeReportServer = $true + + return $null + } -PassThru | + Add-Member -MemberType ScriptMethod -Name RemoveURL { + $script:mockIsMethodCalled_RemoveURL = $true + + return $null + } -PassThru | + Add-Member -MemberType ScriptMethod -Name ListReservedUrls { + $script:mockIsMethodCalled_ListReservedUrls = $true + + return New-Object Object | + Add-Member -MemberType ScriptProperty -Name 'Application' { + return @( + $mockDynamicReportServerApplicationName, + $mockDynamicReportsApplicationName + ) + } -PassThru | + Add-Member -MemberType ScriptProperty -Name 'UrlString' { + return @( + $mockDynamicReportsApplicationUrlString, + $mockDynamicReportServerApplicationUrlString + ) } -PassThru -Force + } -PassThru -Force ), ( # Array is a regression test for issue #819. @@ -109,39 +141,39 @@ try Add-Member -MemberType NoteProperty -Name 'VirtualDirectoryReportServer' -Value '' -PassThru | Add-Member -MemberType NoteProperty -Name 'VirtualDirectoryReportManager' -Value '' -PassThru | Add-Member -MemberType ScriptMethod -Name SetVirtualDirectory { - $script:mockIsMethodCalled_SetVirtualDirectory = $true + $script:mockIsMethodCalled_SetVirtualDirectory = $true - return $null - } -PassThru | + return $null + } -PassThru | Add-Member -MemberType ScriptMethod -Name ReserveURL { - $script:mockIsMethodCalled_ReserveURL = $true + $script:mockIsMethodCalled_ReserveURL = $true - return $null - } -PassThru | + return $null + } -PassThru | Add-Member -MemberType ScriptMethod -Name GenerateDatabaseCreationScript { - $script:mockIsMethodCalled_GenerateDatabaseCreationScript = $true + $script:mockIsMethodCalled_GenerateDatabaseCreationScript = $true - return @{ - Script = 'select * from something' - } - } -PassThru | + return @{ + Script = 'select * from something' + } + } -PassThru | Add-Member -MemberType ScriptMethod -Name GenerateDatabaseRightsScript { - $script:mockIsMethodCalled_GenerateDatabaseRightsScript = $true + $script:mockIsMethodCalled_GenerateDatabaseRightsScript = $true - return @{ - Script = 'select * from something' - } - } -PassThru | + return @{ + Script = 'select * from something' + } + } -PassThru | Add-Member -MemberType ScriptMethod -Name SetDatabaseConnection { - $script:mockIsMethodCalled_SetDatabaseConnection = $true + $script:mockIsMethodCalled_SetDatabaseConnection = $true - return $null - } -PassThru | + return $null + } -PassThru | Add-Member -MemberType ScriptMethod -Name InitializeReportServer { - $script:mockIsMethodCalled_InitializeReportServer = $true + $script:mockIsMethodCalled_InitializeReportServer = $true - return $null - } -PassThru -Force + return $null + } -PassThru -Force } $mockGetWmiObject_ConfigurationSetting_ParameterFilter = { @@ -165,13 +197,22 @@ try Mock -CommandName Get-ItemProperty -MockWith $mockGetItemProperty -Verifiable $defaultParameters = @{ - InstanceName = $mockNamedInstanceName - RSSQLServer = $mockReportingServicesDatabaseServerName + InstanceName = $mockNamedInstanceName + RSSQLServer = $mockReportingServicesDatabaseServerName RSSQLInstanceName = $mockReportingServicesDatabaseNamedInstanceName } } Context 'When the system is in the desired state' { + BeforeAll { + $mockDynamicReportServerApplicationName = $mockReportServerApplicationName + $mockDynamicReportsApplicationName = $mockReportsApplicationName + $mockDynamicReportsApplicationUrlString = $mockReportsApplicationUrl + $mockDynamicReportServerApplicationUrlString = $mockReportServerApplicationUrl + + $mockDynamicIsInitialized = $true + } + BeforeEach { Mock -CommandName Get-WmiObject ` -MockWith $mockGetWmiObject_ConfigurationSetting_NamedInstance ` @@ -192,10 +233,18 @@ try It 'Should return the the state as initialized' { $resultGetTargetResource = Get-TargetResource @defaultParameters $resultGetTargetResource.IsInitialized | Should Be $true + $resultGetTargetResource.ReportServerVirtualDirectory | Should Be $mockVirtualDirectoryReportServerName + $resultGetTargetResource.ReportsVirtualDirectory | Should Be $mockVirtualDirectoryReportManagerName + $resultGetTargetResource.ReportServerReservedUrl | Should Be $mockReportServerApplicationUrl + $resultGetTargetResource.ReportsReservedUrl | Should Be $mockReportsApplicationUrl } } Context 'When the system is not in the desired state' { + BeforeAll { + $mockDynamicIsInitialized = $false + } + BeforeEach { Mock -CommandName Get-WmiObject ` -MockWith $mockGetWmiObject_ConfigurationSetting_DefaultInstance ` @@ -219,6 +268,10 @@ try It 'Should return the state as not initialized' { $resultGetTargetResource = Get-TargetResource @testParameters $resultGetTargetResource.IsInitialized | Should Be $false + $resultGetTargetResource.ReportServerVirtualDirectory | Should BeNullOrEmpty + $resultGetTargetResource.ReportsVirtualDirectory | Should BeNullOrEmpty + $resultGetTargetResource.ReportServerReservedUrl | Should BeNullOrEmpty + $resultGetTargetResource.ReportsReservedUrl | Should BeNullOrEmpty } # Regression test for issue #822. @@ -264,17 +317,18 @@ try } Context 'When the system is not in the desired state' { - Context 'When configuring a named instance' { + Context 'When configuring a named instance that are not initialized' { BeforeAll { $mockDynamic_SqlBuildVersion = '13.0.4001.0' + $mockDynamicIsInitialized = $false Mock -CommandName Test-TargetResource -MockWith { return $true } $defaultParameters = @{ - InstanceName = $mockNamedInstanceName - RSSQLServer = $mockReportingServicesDatabaseServerName + InstanceName = $mockNamedInstanceName + RSSQLServer = $mockReportingServicesDatabaseServerName RSSQLInstanceName = $mockReportingServicesDatabaseNamedInstanceName } } @@ -325,19 +379,94 @@ try { Set-TargetResource @defaultParameters } | Should Throw 'Test-TargetResource returned false after calling set.' } } + + Context 'When it is not possible to evaluate OSLanguage' { + BeforeEach { + Mock -CommandName Get-WmiObject -MockWith { + return $null + } -ParameterFilter $mockGetWmiObject_OperatingSystem_ParameterFilter -Verifiable } + + It 'Should throw the correct error message' { + { Set-TargetResource @defaultParameters } | Should Throw 'Unable to find WMI object Win32_OperatingSystem.' + } + } + } + + Context 'When configuring a named instance that are already initialized' { + BeforeAll { + $mockDynamic_SqlBuildVersion = '13.0.4001.0' + $mockDynamicIsInitialized = $true + + Mock -CommandName Get-TargetResource -MockWith { + return @{ + ReportServerReservedUrl = $mockReportServerApplicationUrl + ReportsReservedUrl = $mockReportsApplicationUrl + } + } + + Mock -CommandName Test-TargetResource -MockWith { + return $true + } + + $testParameters = @{ + InstanceName = $mockNamedInstanceName + RSSQLServer = $mockReportingServicesDatabaseServerName + RSSQLInstanceName = $mockReportingServicesDatabaseNamedInstanceName + ReportServerVirtualDirectory = 'ReportServer_NewName' + ReportsVirtualDirectory = 'Reports_NewName' + ReportServerReservedUrl = 'https://+:4443' + ReportsReservedUrl = 'https://+:4443' + } + } + + BeforeEach { + Mock -CommandName Get-WmiObject ` + -MockWith $mockGetWmiObject_ConfigurationSetting_NamedInstance ` + -ParameterFilter $mockGetWmiObject_ConfigurationSetting_ParameterFilter ` + -Verifiable + + Mock -CommandName Get-WmiObject ` + -MockWith $mockGetWmiObject_Language ` + -ParameterFilter $mockGetWmiObject_OperatingSystem_ParameterFilter ` + -Verifiable + + # Start each test with each method in correct state. + $script:mockIsMethodCalled_GenerateDatabaseCreationScript = $false + $script:mockIsMethodCalled_GenerateDatabaseRightsScript = $false + $script:mockIsMethodCalled_SetVirtualDirectory = $false + $script:mockIsMethodCalled_ReserveURL = $false + $script:mockIsMethodCalled_SetDatabaseConnection = $false + $script:mockIsMethodCalled_InitializeReportServer = $false + } + + It 'Should configure Reporting Service without throwing an error' { + { Set-TargetResource @testParameters } | Should Not Throw + + # Test so each mock of methods was called. + $script:mockIsMethodCalled_GenerateDatabaseRightsScript | Should Be $false + $script:mockIsMethodCalled_GenerateDatabaseCreationScript | Should Be $false + $script:mockIsMethodCalled_SetVirtualDirectory | Should Be $true + $script:mockIsMethodCalled_ReserveURL | Should Be $true + $script:mockIsMethodCalled_SetDatabaseConnection | Should Be $false + $script:mockIsMethodCalled_InitializeReportServer | Should Be $false + + Assert-MockCalled -CommandName Get-WmiObject -Exactly -Times 2 -Scope It + Assert-MockCalled -CommandName Invoke-Sqlcmd -Exactly -Times 0 -Scope It + } } - Context 'When configuring a default instance' { + Context 'When configuring a default instance that are not initialized' { BeforeAll { $mockDynamic_SqlBuildVersion = '12.0.4100.1' + $mockDynamicIsInitialized = $false Mock -CommandName Test-TargetResource -MockWith { return $true } -Verifiable $defaultParameters = @{ - InstanceName = $mockDefaultInstanceName - RSSQLServer = $mockReportingServicesDatabaseServerName + InstanceName = $mockDefaultInstanceName + RSSQLServer = $mockReportingServicesDatabaseServerName RSSQLInstanceName = $mockReportingServicesDatabaseDefaultInstanceName } } @@ -377,23 +506,121 @@ try Describe "xSQLServerRSConfig\Test-TargetResource" -Tag 'Test' { Context 'When the system is not in the desired state' { - BeforeAll { - Mock -CommandName Get-TargetResource -MockWith { - return @{ - IsInitialized = $false + Context 'When Reporting Services are not initialized' { + BeforeAll { + Mock -CommandName Get-TargetResource -MockWith { + return @{ + IsInitialized = $false + } + } -Verifiable + + $testParameters = @{ + InstanceName = $mockNamedInstanceName + RSSQLServer = $mockReportingServicesDatabaseServerName + RSSQLInstanceName = $mockReportingServicesDatabaseNamedInstanceName } - } -Verifiable + } - $defaultParameters = @{ - InstanceName = $mockNamedInstanceName - RSSQLServer = $mockReportingServicesDatabaseServerName - RSSQLInstanceName = $mockReportingServicesDatabaseNamedInstanceName + It 'Should return state as not in desired state' { + $resultTestTargetResource = Test-TargetResource @testParameters + $resultTestTargetResource | Should Be $false } } - It 'Should return state as not in desired state' { - $resultTestTargetResource = Test-TargetResource @defaultParameters - $resultTestTargetResource | Should Be $false + Context 'When Report Server virtual directory is different' { + BeforeAll { + Mock -CommandName Get-TargetResource -MockWith { + return @{ + IsInitialized = $true + ReportServerVirtualDirectory = $mockVirtualDirectoryReportServerName + ReportsVirtualDirectory = $mockVirtualDirectoryReportsName + } + } -Verifiable + + $testParameters = @{ + InstanceName = $mockNamedInstanceName + RSSQLServer = $mockReportingServicesDatabaseServerName + RSSQLInstanceName = $mockReportingServicesDatabaseNamedInstanceName + ReportsVirtualDirectory = $mockVirtualDirectoryReportsName + ReportServerVirtualDirectory = 'ReportServer_NewName' + } + } + + It 'Should return state as not in desired state' { + $resultTestTargetResource = Test-TargetResource @testParameters + $resultTestTargetResource | Should Be $false + } + } + + Context 'When Report Server virtual directory is different' { + BeforeAll { + Mock -CommandName Get-TargetResource -MockWith { + return @{ + IsInitialized = $true + ReportServerVirtualDirectory = $mockVirtualDirectoryReportServerName + ReportsVirtualDirectory = $mockVirtualDirectoryReportsName + } + } -Verifiable + + $testParameters = @{ + InstanceName = $mockNamedInstanceName + RSSQLServer = $mockReportingServicesDatabaseServerName + RSSQLInstanceName = $mockReportingServicesDatabaseNamedInstanceName + ReportServerVirtualDirectory = $mockVirtualDirectoryReportServerName + ReportsVirtualDirectory = 'Reports_NewName' + } + } + + It 'Should return state as not in desired state' { + $resultTestTargetResource = Test-TargetResource @testParameters + $resultTestTargetResource | Should Be $false + } + } + + Context 'When Report Server Report Server reserved URLs is different' { + BeforeAll { + Mock -CommandName Get-TargetResource -MockWith { + return @{ + IsInitialized = $true + ReportServerReservedUrl = $mockReportServerApplicationUrl + } + } -Verifiable + + $testParameters = @{ + InstanceName = $mockNamedInstanceName + RSSQLServer = $mockReportingServicesDatabaseServerName + RSSQLInstanceName = $mockReportingServicesDatabaseNamedInstanceName + ReportServerReservedUrl = 'https://+:443' + } + } + + It 'Should return state as not in desired state' { + $resultTestTargetResource = Test-TargetResource @testParameters + $resultTestTargetResource | Should Be $false + } + } + + Context 'When Report Server Reports reserved URLs is different' { + BeforeAll { + Mock -CommandName Get-TargetResource -MockWith { + return @{ + IsInitialized = $true + ReportsReservedUrl = $mockReportServerApplicationUrl + } + } -Verifiable + + $testParameters = @{ + InstanceName = $mockNamedInstanceName + RSSQLServer = $mockReportingServicesDatabaseServerName + RSSQLInstanceName = $mockReportingServicesDatabaseNamedInstanceName + ReportsReservedUrl = 'https://+:443' + } + } + + It 'Should return state as not in desired state' { + $resultTestTargetResource = Test-TargetResource @testParameters + $resultTestTargetResource | Should Be $false + } } } @@ -406,14 +633,14 @@ try } -Verifiable $defaultParameters = @{ - InstanceName = $mockNamedInstanceName - RSSQLServer = $mockReportingServicesDatabaseServerName + InstanceName = $mockNamedInstanceName + RSSQLServer = $mockReportingServicesDatabaseServerName RSSQLInstanceName = $mockReportingServicesDatabaseNamedInstanceName } } It 'Should return state as in desired state' { - $resultTestTargetResource = Test-TargetResource @defaultParameters + $resultTestTargetResource = Test-TargetResource @defaultParameters $resultTestTargetResource | Should Be $true } }