-
Notifications
You must be signed in to change notification settings - Fork 226
Get-SqlDscRSConfigurationSetting: new public function #2348
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
671925f
Add Get-SqlDscRSConfigurationSetting function with Unit and integrati…
Sidoran 5a479cd
Update CHANGELOG.md to include the addition of the `Get-SqlDscRSConfi…
Sidoran 2fad7de
Remove unused string for instance not found in namespace from SqlServ…
Sidoran a465f46
Fix error message formatting in Get-SqlDscRSConfigurationSetting func…
Sidoran 059da4a
Update integration tests for Get-SqlDscRSConfigurationSetting to incl…
Sidoran 0396e38
Add parameter set validation tests for Get-SqlDscRSConfigurationSetti…
Sidoran 1062775
Update Get-SqlDscRSConfigurationSetting documentation to correct para…
Sidoran c8fcd47
Enhance integration test for Get-SqlDscRSConfigurationSetting by enfo…
Sidoran b070989
Update output type in Get-SqlDscRSConfigurationSetting function to us…
Sidoran 037c3fc
Add Get-SqlDscRSConfigurationSetting integration tests to azure-pipel…
Sidoran 305d7db
Refactor integration tests for Get-SqlDscRSConfigurationSetting to te…
Sidoran a643e82
Update integration tests for Get-SqlDscRSConfigurationSetting to asse…
Sidoran 826edee
Re-enable version checks in Get-SqlDscRSConfigurationSetting integrat…
Sidoran 5cf516d
Temporarily disable version checks in Get-SqlDscRSConfigurationSettin…
Sidoran File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| ) | ||
| ) | ||
| } | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| # 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 | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.