Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
14 commits
Select commit Hold shift + click to select a range
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
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- Added public command `Get-SqlDscRSConfigurationSetting` to retrieve SQL Server
Reporting Services configuration settings from the MSReportServer_ConfigurationSetting
WMI class. The command returns configuration information including initialization
status, database configuration, virtual directories, service account, TLS configuration,
and other settings. It supports retrieving settings for all instances or a specific
instance by name. The command uses `Get-SqlDscRSSetupConfiguration` to discover
instances and determine the SQL version for proper WMI namespace construction.
Properties returned are limited to those available in the MSReportServer_ConfigurationSetting
class, with `SecureConnectionLevel` converted to boolean `IsTlsConfigured` property
[issue #2011](https://github.com/dsccommunity/SqlServerDsc/issues/2011).
- Added public command `Set-SqlDscDatabaseOwner` to change the owner of a SQL Server
database [issue #2177](https://github.com/dsccommunity/SqlServerDsc/issues/2177).
This command uses the SMO `SetOwner()` method and supports both `ServerObject`
Expand Down
2 changes: 2 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,7 @@ stages:
# Group 2
'tests/Integration/Commands/Get-SqlDscInstalledInstance.Integration.Tests.ps1'
'tests/Integration/Commands/Get-SqlDscRSSetupConfiguration.Integration.Tests.ps1'
'tests/Integration/Commands/Get-SqlDscRSConfigurationSetting.Integration.Tests.ps1'
'tests/Integration/Commands/Test-SqlDscRSInstalled.Integration.Tests.ps1'
# Group 8
'tests/Integration/Commands/Repair-SqlDscReportingService.Integration.Tests.ps1'
Expand Down Expand Up @@ -583,6 +584,7 @@ stages:
# Group 2
'tests/Integration/Commands/Get-SqlDscInstalledInstance.Integration.Tests.ps1'
'tests/Integration/Commands/Get-SqlDscRSSetupConfiguration.Integration.Tests.ps1'
'tests/Integration/Commands/Get-SqlDscRSConfigurationSetting.Integration.Tests.ps1'
'tests/Integration/Commands/Test-SqlDscRSInstalled.Integration.Tests.ps1'
# Group 8
'tests/Integration/Commands/Repair-SqlDscBIReportServer.Integration.Tests.ps1'
Expand Down
214 changes: 214 additions & 0 deletions source/Public/Get-SqlDscRSConfigurationSetting.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,214 @@
<#
.SYNOPSIS
Gets the SQL Server Reporting Services configuration settings from the
MSReportServer_ConfigurationSetting WMI class.

.DESCRIPTION
Gets the SQL Server Reporting Services configuration settings from the
MSReportServer_ConfigurationSetting WMI class for installed Reporting Services
instances. This includes information like initialization status, database
configuration, virtual directories, service account, and other configuration
settings.

When no InstanceName is specified, it returns configuration information for all
installed Reporting Services instances.

.PARAMETER InstanceName
Specifies the instance name to return configuration information for.
If not specified, configuration information for all Reporting Services
instances will be returned.

.EXAMPLE
Get-SqlDscRSConfigurationSetting

Returns configuration settings for all SQL Server Reporting Services instances.

.EXAMPLE
Get-SqlDscRSConfigurationSetting -InstanceName 'SSRS'

Returns configuration settings for the SQL Server Reporting Services
instance 'SSRS'.

.OUTPUTS
Returns a PSCustomObject array with the following properties from
MSReportServer_ConfigurationSetting:
- InstanceName: The name of the Reporting Services instance.
- Version: The version of the Reporting Services instance.
- PathName: The Reporting Services configuration file path.
- InstallationID: The Reporting Services unique installation identifier.
- IsInitialized: Whether the instance is initialized.
- IsSharePointIntegrated: Whether the instance is SharePoint integrated.
- IsWebServiceEnabled: Whether the Web service is enabled.
- IsWindowsServiceEnabled: Whether the Windows service is enabled.
- IsTlsConfigured: Whether TLS is configured (true if SecureConnectionLevel >= 1, false if 0).
- DatabaseServerName: The database server name.
- DatabaseName: The database name.
- DatabaseLogonType: The database login type.
- DatabaseLogonAccount: The database login account.
- ServiceAccount: The Windows service account (from WindowsServiceIdentityActual).
- WebServiceApplicationName: The Web service application name (ReportServerWebService).
- WebServiceVirtualDirectory: The Web service virtual directory (from VirtualDirectoryReportServer).
- WebPortalApplicationName: The Web portal application name (ReportServerWebApp or ReportManager).
- WebPortalVirtualDirectory: The Web portal virtual directory (from VirtualDirectoryReportManager).
#>
function Get-SqlDscRSConfigurationSetting
{
[CmdletBinding()]
[OutputType([System.Management.Automation.PSCustomObject])]
param
(
[Parameter()]
[System.String]
$InstanceName
)

$reportingServicesInstances = @()

# Get all Reporting Services instances or filter by specified instance name
$getRSSetupConfigurationParams = @{}

if ($PSBoundParameters.ContainsKey('InstanceName'))
{
Write-Verbose -Message ($script:localizedData.Get_SqlDscRSConfigurationSetting_GetSpecificInstance -f $InstanceName)
$getRSSetupConfigurationParams.InstanceName = $InstanceName
}
else
{
Write-Verbose -Message $script:localizedData.Get_SqlDscRSConfigurationSetting_GetAllInstances
}

$setupConfigurations = Get-SqlDscRSSetupConfiguration @getRSSetupConfigurationParams

foreach ($setupConfig in $setupConfigurations)
{
Write-Verbose -Message ($script:localizedData.Get_SqlDscRSConfigurationSetting_ProcessingInstance -f $setupConfig.InstanceName)

# Initialize return object with InstanceName and null/default values
$returnObject = [PSCustomObject]@{
InstanceName = $setupConfig.InstanceName
Version = $null
PathName = $null
InstallationID = $null
IsInitialized = $null
IsSharePointIntegrated = $null
IsWebServiceEnabled = $null
IsWindowsServiceEnabled = $null
IsTlsConfigured = $null
DatabaseServerName = $null
DatabaseName = $null
DatabaseLogonType = $null
DatabaseLogonAccount = $null
ServiceAccount = $null
WebServiceApplicationName = 'ReportServerWebService'
WebServiceVirtualDirectory = $null
WebPortalApplicationName = $null
WebPortalVirtualDirectory = $null
}

# Error if CurrentVersion is empty (cannot determine namespace)
if ([System.String]::IsNullOrEmpty($setupConfig.CurrentVersion))
{
$errorMessage = $script:localizedData.Get_SqlDscRSConfigurationSetting_CurrentVersionEmpty -f $setupConfig.InstanceName

$PSCmdlet.ThrowTerminatingError(
[System.Management.Automation.ErrorRecord]::new(
$errorMessage,
'GSDCRSCS0001', # cspell: disable-line
[System.Management.Automation.ErrorCategory]::InvalidOperation,
$setupConfig.InstanceName
)
)
}

# Parse CurrentVersion to get major version number
try
{
$reportServerCurrentVersion = [System.Version] $setupConfig.CurrentVersion
$sqlMajorVersion = $reportServerCurrentVersion.Major

Write-Verbose -Message ($script:localizedData.Get_SqlDscRSConfigurationSetting_FoundInstance -f $setupConfig.InstanceName, $sqlMajorVersion)
}
catch
{
$errorMessage = $script:localizedData.Get_SqlDscRSConfigurationSetting_InvalidVersion -f $setupConfig.CurrentVersion, $setupConfig.InstanceName

$PSCmdlet.ThrowTerminatingError(
[System.Management.Automation.ErrorRecord]::new(
$errorMessage,
'GSDCRSCS0002', # cspell: disable-line
[System.Management.Automation.ErrorCategory]::InvalidArgument,
$setupConfig.CurrentVersion
)
)
}

# Get MSReportServer_ConfigurationSetting instance
$getCimInstanceParameters = @{
Filter = "InstanceName='{0}'" -f $returnObject.InstanceName
Namespace = 'root\Microsoft\SQLServer\ReportServer\RS_{0}\v{1}\Admin' -f $returnObject.InstanceName, $sqlMajorVersion
ClassName = 'MSReportServer_ConfigurationSetting'
ErrorAction = 'Stop'
}

try
{
$reportingServicesConfiguration = Get-CimInstance @getCimInstanceParameters
}
catch
{
$errorMessage = $script:localizedData.Get_SqlDscRSConfigurationSetting_ConfigurationNotFound -f $setupConfig.InstanceName, $getCimInstanceParameters.Namespace, $_.Exception.Message

$PSCmdlet.ThrowTerminatingError(
[System.Management.Automation.ErrorRecord]::new(
$errorMessage,
'GSDCRSCS0003', # cspell: disable-line
[System.Management.Automation.ErrorCategory]::InvalidOperation,
$setupConfig.InstanceName
)
)
}

# Determine Web Portal Application Name based on SQL version
if ($sqlMajorVersion -ge 13)
{
$returnObject.WebPortalApplicationName = 'ReportServerWebApp'
}
else
{
$returnObject.WebPortalApplicationName = 'ReportManager'
}

# Populate return object with properties from MSReportServer_ConfigurationSetting
$returnObject.Version = $reportingServicesConfiguration.Version
$returnObject.PathName = $reportingServicesConfiguration.PathName
$returnObject.InstallationID = $reportingServicesConfiguration.InstallationID
$returnObject.IsInitialized = $reportingServicesConfiguration.IsInitialized
$returnObject.IsSharePointIntegrated = $reportingServicesConfiguration.IsSharePointIntegrated
$returnObject.IsWebServiceEnabled = $reportingServicesConfiguration.IsWebServiceEnabled
$returnObject.IsWindowsServiceEnabled = $reportingServicesConfiguration.IsWindowsServiceEnabled
$returnObject.IsTlsConfigured = $reportingServicesConfiguration.SecureConnectionLevel -ge 1
$returnObject.DatabaseServerName = $reportingServicesConfiguration.DatabaseServerName
$returnObject.DatabaseName = $reportingServicesConfiguration.DatabaseName
$returnObject.DatabaseLogonType = $reportingServicesConfiguration.DatabaseLogonType
$returnObject.DatabaseLogonAccount = $reportingServicesConfiguration.DatabaseLogonAccount
$returnObject.ServiceAccount = $reportingServicesConfiguration.WindowsServiceIdentityActual
$returnObject.WebServiceVirtualDirectory = $reportingServicesConfiguration.VirtualDirectoryReportServer
$returnObject.WebPortalVirtualDirectory = $reportingServicesConfiguration.VirtualDirectoryReportManager

$reportingServicesInstances += $returnObject
}

if ($reportingServicesInstances.Count -eq 0)
{
if ($PSBoundParameters.ContainsKey('InstanceName'))
{
Write-Verbose -Message ($script:localizedData.Get_SqlDscRSConfigurationSetting_InstanceNotFound -f $InstanceName)
}
else
{
Write-Verbose -Message $script:localizedData.Get_SqlDscRSConfigurationSetting_NoInstancesFound
}
}

return $reportingServicesInstances
}
11 changes: 11 additions & 0 deletions source/en-US/SqlServerDsc.strings.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,17 @@ ConvertFrom-StringData @'
Get_SqlDscRSSetupConfiguration_InstanceNotFound = Could not find a Microsoft SQL Server Reporting Services instance with the name '{0}'.
Get_SqlDscRSSetupConfiguration_NoInstancesFound = No SQL Server Reporting Services instances were found.

## Get-SqlDscRSConfigurationSetting
Get_SqlDscRSConfigurationSetting_GetAllInstances = Getting all SQL Server Reporting Services configuration settings.
Get_SqlDscRSConfigurationSetting_GetSpecificInstance = Getting SQL Server Reporting Services configuration settings for instance '{0}'.
Get_SqlDscRSConfigurationSetting_FoundInstance = Found a Microsoft SQL Server Reporting Services instance with the name '{0}' (SQL version {1}).
Get_SqlDscRSConfigurationSetting_ProcessingInstance = Processing configuration settings for instance '{0}'.
Get_SqlDscRSConfigurationSetting_InstanceNotFound = Could not find a Microsoft SQL Server Reporting Services instance with the name '{0}'.
Get_SqlDscRSConfigurationSetting_NoInstancesFound = No SQL Server Reporting Services instances were found.
Get_SqlDscRSConfigurationSetting_CurrentVersionEmpty = Cannot get configuration settings for Reporting Services instance '{0}' because CurrentVersion is not available. The instance may not be properly installed or initialized.
Get_SqlDscRSConfigurationSetting_InvalidVersion = Cannot parse CurrentVersion '{0}' for Reporting Services instance '{1}'. The version format is invalid.
Get_SqlDscRSConfigurationSetting_ConfigurationNotFound = Could not find MSReportServer_ConfigurationSetting for instance '{0}' in namespace '{1}'. Error: {2}

## Test-SqlDscRSInstalled
Test_SqlDscRSInstalled_Checking = Checking if Reporting Services instance '{0}' is installed.
Test_SqlDscRSInstalled_Found = Reporting Services instance '{0}' was found.
Expand Down
Loading
Loading