Add functions to enable and disable TLS for Reporting Services#2387
Add functions to enable and disable TLS for Reporting Services#2387johlju merged 14 commits intodsccommunity:mainfrom
Conversation
WalkthroughAdds public Reporting Services configuration retrieval and TLS management cmdlets, a private CIM-invocation helper, refactors DSC_SqlRS to call the new TLS cmdlets, adds localization strings, unit and integration tests, CI test entries, and removes one previously exported symbol. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor User
participant Cmd as Enable/Disable Cmdlet
participant Invoker as Invoke-RsCimMethod
participant CIM as ReportingServices CIM
User->>Cmd: Provide Configuration CIM (pipeline) + flags (-Force/-PassThru)
Cmd->>Cmd: ShouldProcess / respect -Force
Cmd->>Invoker: Invoke SetSecureConnectionLevel(Level=1|0) on provided CIM
Invoker->>CIM: Invoke-CimMethod SetSecureConnectionLevel
alt Success (HRESULT = 0)
CIM-->>Invoker: CimMethodResult (HRESULT=0)
Invoker-->>Cmd: Return CimMethodResult
alt -PassThru
Cmd-->>User: Return input CIM instance
else
Cmd-->>User: No output (success)
end
else Failure (HRESULT ≠ 0)
CIM-->>Invoker: CimMethodResult + ExtendedErrors/Error
Invoker->>Invoker: Aggregate error text
Invoker-->>Cmd: Throw terminating error
Cmd-->>User: Propagate terminating error
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Pre-merge checks✅ Passed checks (5 passed)
📜 Recent review detailsConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (6)source/**/*.ps1📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines-localization.instructions.md)
Files:
⚙️ CodeRabbit configuration file
Files:
source/Public/*.ps1📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines.instructions.md)
Files:
**/*.{ps1,psm1,psd1}📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines-powershell.instructions.md)
Files:
**/Public/**/*.ps1📄 CodeRabbit inference engine (.github/instructions/SqlServerDsc-guidelines.instructions.md)
Files:
**⚙️ CodeRabbit configuration file
Files:
{**/*.ps1,**/*.psm1,**/*.psd1}⚙️ CodeRabbit configuration file
Files:
🧠 Learnings (16)📓 Common learnings📚 Learning: 2026-01-01T11:57:15.286ZApplied to files:
📚 Learning: 2025-10-03T15:27:24.417ZApplied to files:
📚 Learning: 2025-12-10T20:07:45.822ZApplied to files:
📚 Learning: 2025-12-24T18:09:36.332ZApplied to files:
📚 Learning: 2025-11-27T17:59:01.508ZApplied to files:
📚 Learning: 2025-11-27T17:58:20.404ZApplied to files:
📚 Learning: 2025-11-27T17:59:01.508ZApplied to files:
📚 Learning: 2025-12-24T18:09:36.332ZApplied to files:
📚 Learning: 2025-11-27T17:59:01.508ZApplied to files:
📚 Learning: 2025-12-24T18:09:36.332ZApplied to files:
📚 Learning: 2025-11-27T17:59:01.508ZApplied to files:
📚 Learning: 2025-11-27T17:59:01.508ZApplied to files:
📚 Learning: 2025-12-24T18:09:36.332ZApplied to files:
📚 Learning: 2025-11-27T17:59:01.508ZApplied to files:
📚 Learning: 2025-11-27T17:59:01.508ZApplied to files:
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
🔇 Additional comments (5)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
source/DSCResources/DSC_SqlRS/DSC_SqlRS.psm1 (1)
821-836: Inconsistent TLS configuration approach.Lines 607-614 use the new public commands (
Enable-SqlDscRSTls/Disable-SqlDscRSTls), but this code path still uses direct CIM method invocation. For consistency and maintainability, both paths should use the same approach.🔎 Refactor to use the same public commands
if ( $PSBoundParameters.ContainsKey('UseSsl') -and $UseSsl -ne $currentConfig.UseSsl ) { Write-Verbose -Message "Changing value for using SSL to '$UseSsl'." $restartReportingService = $true - $invokeRsCimMethodParameters = @{ - CimInstance = $reportingServicesData.Configuration - MethodName = 'SetSecureConnectionLevel' - Arguments = @{ - Level = @(0, 1)[$UseSsl] - } + if ($UseSsl) + { + $reportingServicesData.Configuration | Enable-SqlDscRSTls -Force + } + else + { + $reportingServicesData.Configuration | Disable-SqlDscRSTls -Force } - - Invoke-RsCimMethod @invokeRsCimMethodParameters }
🧹 Nitpick comments (7)
tests/Integration/Commands/Enable-SqlDscRSTls.Integration.Tests.ps1 (2)
76-107: Consider adding PassThru test for completeness.The SQL Server 2019 RS context tests TLS enablement but doesn't include a PassThru test like the 2017 and PBIRS contexts do. For consistency and complete coverage, consider adding a PassThru test here as well.
🔎 Add PassThru test
It 'Should enable TLS using pipeline' { # First ensure TLS is disabled $script:configuration | Disable-SqlDscRSTls -Force # Enable TLS $config = Get-SqlDscRSConfiguration -InstanceName 'SSRS' $config | Enable-SqlDscRSTls -Force # Verify TLS is enabled (level 1 or higher means enabled) $verifyConfig = Get-SqlDscRSConfiguration -InstanceName 'SSRS' $verifyConfig.SecureConnectionLevel | Should -BeGreaterOrEqual 1 } + + It 'Should return configuration when using PassThru' { + $config = Get-SqlDscRSConfiguration -InstanceName 'SSRS' + $result = $config | Enable-SqlDscRSTls -Force -PassThru + + $result | Should -Not -BeNullOrEmpty + $result.InstanceName | Should -Be 'SSRS' + } }
109-140: Consider adding PassThru test for completeness.The SQL Server 2022 RS context tests TLS enablement but doesn't include a PassThru test like the 2017 and PBIRS contexts do. For consistency and complete coverage, consider adding a PassThru test here as well.
🔎 Add PassThru test
It 'Should enable TLS using pipeline' { # First ensure TLS is disabled $script:configuration | Disable-SqlDscRSTls -Force # Enable TLS $config = Get-SqlDscRSConfiguration -InstanceName 'SSRS' $config | Enable-SqlDscRSTls -Force # Verify TLS is enabled (level 1 or higher means enabled) $verifyConfig = Get-SqlDscRSConfiguration -InstanceName 'SSRS' $verifyConfig.SecureConnectionLevel | Should -BeGreaterOrEqual 1 } + + It 'Should return configuration when using PassThru' { + $config = Get-SqlDscRSConfiguration -InstanceName 'SSRS' + $result = $config | Enable-SqlDscRSTls -Force -PassThru + + $result | Should -Not -BeNullOrEmpty + $result.InstanceName | Should -Be 'SSRS' + } }tests/Integration/Commands/Disable-SqlDscRSTls.Integration.Tests.ps1 (3)
35-35: Consider making Context descriptions unique per SQL Server version.The Context descriptions on lines 35, 81, and 114 are identical: "When disabling TLS for SQL Server Reporting Services". While the tags differentiate them, unique descriptions would improve test output readability:
- Context 'When disabling TLS for SQL Server Reporting Services' -Tag @('Integration_SQL2017_RS') { + Context 'When disabling TLS for SQL Server 2017 Reporting Services' -Tag @('Integration_SQL2017_RS') {Also applies to: 81-81, 114-114
81-112: Missing PassThru test for SQL2019_RS context.The SQL2017_RS and PowerBI contexts include a
'Should return configuration when using PassThru'test, but the SQL2019_RS context only has the pipeline test. Consider adding PassThru coverage for consistency across all RS versions.
114-145: Missing PassThru test for SQL2022_RS context.Similar to SQL2019_RS, this context is missing the PassThru validation test. For comprehensive coverage, consider adding:
It 'Should return configuration when using PassThru' { # First enable TLS $config = Get-SqlDscRSConfiguration -InstanceName 'SSRS' $config | Enable-SqlDscRSTls -Force # Disable with PassThru $config = Get-SqlDscRSConfiguration -InstanceName 'SSRS' $result = $config | Disable-SqlDscRSTls -Force -PassThru $result | Should -Not -BeNullOrEmpty $result.InstanceName | Should -Be 'SSRS' }tests/Unit/Private/Invoke-RsCimMethod.Tests.ps1 (1)
77-78: Omit-ModuleNameparameter per PSDefaultParameterValues.The
-ModuleNameparameter is explicitly specified but PSDefaultParameterValues already sets it. Per guidelines, omit-ModuleNameon Pester commands when using PSDefaultParameterValues.- InModuleScope -ModuleName $script:moduleName -ScriptBlock { + InModuleScope -ScriptBlock {CHANGELOG.md (1)
112-115: SqlRS refactor entry looks good; consider noting any public-surface changes separatelyThe
SqlRSchange description correctly states the switch toEnable-SqlDscRSTls/Disable-SqlDscRSTls. If this PR also changes public behavior or exported surface (for example, around TLS-related parameters or helper exposure), consider adding a short extra bullet under either Changed or Removed in the Unreleased section to capture that explicitly.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2387 +/- ##
=====================================
Coverage 94% 94%
=====================================
Files 174 178 +4
Lines 10157 10231 +74
=====================================
+ Hits 9556 9628 +72
- Misses 601 603 +2
🚀 New features to boost your workflow:
|
… Reporting Services - Implemented `Disable-SqlDscRsSecureConnection` to disable TLS/SSL by setting the secure connection level to 0. - Implemented `Enable-SqlDscRsSecureConnection` to enable TLS/SSL by setting the secure connection level to 1. - Updated `Get-SqlDscRSConfiguration` documentation to reference the new functions. - Added localization strings for the new functions. - Created integration tests for both `Enable-SqlDscRsSecureConnection` and `Disable-SqlDscRsSecureConnection`. - Created unit tests for both functions to ensure proper functionality and error handling.
…ureConnection in unit tests
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (8)
source/Public/Get-SqlDscRSConfiguration.ps1 (1)
78-85: Consider usingNew-ErrorRecordhelper for error handling.Per coding guidelines, use
New-ErrorRecordinstead of[System.Management.Automation.ErrorRecord]::new(...)for error handling. This provides a more consistent approach across the codebase.🔎 Example refactor for one error instance
- $PSCmdlet.ThrowTerminatingError( - [System.Management.Automation.ErrorRecord]::new( - [System.InvalidOperationException]::new($errorMessage), - 'GSRSCD0001', - [System.Management.Automation.ErrorCategory]::ObjectNotFound, - $InstanceName - ) - ) + $errorRecord = New-ErrorRecord ` + -Exception ([System.InvalidOperationException]::new($errorMessage)) ` + -ErrorId 'GSRSCD0001' ` + -ErrorCategory 'ObjectNotFound' ` + -TargetObject $InstanceName + + $PSCmdlet.ThrowTerminatingError($errorRecord)Also applies to: 92-99, 121-128, 141-148
source/DSCResources/DSC_SqlRS/DSC_SqlRS.psm1 (1)
821-836: Inconsistent SSL handling between initialization and already-initialized paths.The initialization path (lines 607-614) uses the new public commands
Enable-SqlDscRsSecureConnectionandDisable-SqlDscRsSecureConnection, but the already-initialized path (lines 821-836) still usesInvoke-RsCimMethoddirectly withSetSecureConnectionLevel. Consider refactoring this path to also use the public commands for consistency.🔎 Proposed fix
if ( $PSBoundParameters.ContainsKey('UseSsl') -and $UseSsl -ne $currentConfig.UseSsl ) { Write-Verbose -Message "Changing value for using SSL to '$UseSsl'." $restartReportingService = $true - $invokeRsCimMethodParameters = @{ - CimInstance = $reportingServicesData.Configuration - MethodName = 'SetSecureConnectionLevel' - Arguments = @{ - Level = @(0, 1)[$UseSsl] - } - } - - Invoke-RsCimMethod @invokeRsCimMethodParameters + if ($UseSsl) + { + $reportingServicesData.Configuration | Enable-SqlDscRsSecureConnection -Force + } + else + { + $reportingServicesData.Configuration | Disable-SqlDscRsSecureConnection -Force + } }tests/Integration/Commands/Disable-SqlDscRsSecureConnection.Integration.Tests.ps1 (1)
81-112: Consider addingPassThrutests for SQL2019 and SQL2022 contexts.The SQL2017 and Power BI contexts include a
PassThrutest case, but SQL2019 (lines 81-112) and SQL2022 (lines 114-145) contexts only test the basic disable scenario. For consistent coverage across all versions, consider addingPassThrutests to these contexts as well.Also applies to: 114-145
tests/Integration/Commands/Enable-SqlDscRsSecureConnection.Integration.Tests.ps1 (1)
76-107: Consider addingPassThrutests for SQL2019 and SQL2022 contexts.Similar to the Disable tests, the SQL2019 and SQL2022 contexts are missing
PassThrutests that are present in the SQL2017 and Power BI contexts. For complete coverage, consider adding these tests.Also applies to: 109-140
tests/Unit/Public/Enable-SqlDscRsSecureConnection.Tests.ps1 (1)
82-233: Missing parameter set validation tests.Per coding guidelines, all public commands require parameter set validation tests in unit tests. Consider adding a test to validate the parameter sets using the
Get-Commandpattern:🔎 Example parameter set validation test
Context 'When validating parameter sets' { It 'Should have the correct parameters in parameter set <ExpectedParameterSetName>' -ForEach @( @{ ExpectedParameterSetName = '__AllParameterSets' ExpectedParameters = '[-Configuration] <ciminstance> [-PassThru] [-Force] [-WhatIf] [-Confirm] [<CommonParameters>]' } ) { $result = (Get-Command -Name 'Enable-SqlDscRsSecureConnection').ParameterSets | Where-Object -FilterScript { $_.Name -eq $ExpectedParameterSetName } | Select-Object -Property @( @{ Name = 'ParameterSetName'; Expression = { $_.Name } }, @{ Name = 'ParameterListAsString'; Expression = { $_.ToString() } } ) $result.ParameterSetName | Should -Be $ExpectedParameterSetName $result.ParameterListAsString | Should -Be $ExpectedParameters } }tests/Unit/Public/Disable-SqlDscRsSecureConnection.Tests.ps1 (1)
82-233: Missing parameter set validation tests.Similar to the Enable command tests, this file should include parameter set validation tests per coding guidelines. Consider adding the same pattern as suggested for
Enable-SqlDscRsSecureConnection.Tests.ps1.source/Public/Disable-SqlDscRsSecureConnection.ps1 (1)
126-133: Consider usingNew-ErrorRecordhelper for error handling.Per coding guidelines, error handling should use
New-ErrorRecordinstead of direct[System.Management.Automation.ErrorRecord]::new(...)construction. TheNew-ErrorRecordandNew-Exceptionhelpers from DscResource.Common provide consistent error creation patterns.🔎 Proposed refactor using New-ErrorRecord
catch { $errorMessage = $script:localizedData.Disable_SqlDscRsSecureConnection_FailedToDisable -f $instanceName, $_.Exception.Message - $PSCmdlet.ThrowTerminatingError( - [System.Management.Automation.ErrorRecord]::new( - [System.InvalidOperationException]::new($errorMessage), - 'DSRSSC0001', - [System.Management.Automation.ErrorCategory]::InvalidOperation, - $Configuration - ) - ) + $errorRecord = New-ErrorRecord -Exception (New-Exception -Message $errorMessage -ErrorRecord $_) ` + -ErrorId 'DSRSSC0001' ` + -ErrorCategory 'InvalidOperation' ` + -TargetObject $Configuration + + $PSCmdlet.ThrowTerminatingError($errorRecord) }source/Public/Enable-SqlDscRsSecureConnection.ps1 (1)
130-137: Consider usingNew-ErrorRecordhelper for error handling.Per coding guidelines, error handling should use
New-ErrorRecordinstead of direct[System.Management.Automation.ErrorRecord]::new(...)construction. Same recommendation as theDisable-SqlDscRsSecureConnectionfunction.🔎 Proposed refactor using New-ErrorRecord
catch { $errorMessage = $script:localizedData.Enable_SqlDscRsSecureConnection_FailedToEnable -f $instanceName, $_.Exception.Message - $PSCmdlet.ThrowTerminatingError( - [System.Management.Automation.ErrorRecord]::new( - [System.InvalidOperationException]::new($errorMessage), - 'ESRSSC0001', - [System.Management.Automation.ErrorCategory]::InvalidOperation, - $Configuration - ) - ) + $errorRecord = New-ErrorRecord -Exception (New-Exception -Message $errorMessage -ErrorRecord $_) ` + -ErrorId 'ESRSSC0001' ` + -ErrorCategory 'InvalidOperation' ` + -TargetObject $Configuration + + $PSCmdlet.ThrowTerminatingError($errorRecord) }
…ction for SSL configuration
…nctions to use New-ErrorRecord for improved clarity
…Record for improved clarity
…n to include PassThru functionality
…reConnection functions and enhance parameter set validation in tests
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
tests/Integration/Commands/Disable-SqlDscRsSecureConnection.Integration.Tests.ps1 (1)
81-171: Consider parameterizing the SSRS Context blocks to reduce duplication.The three SSRS Context blocks (SQL2017, SQL2019, SQL2022) have identical logic, differing only by the
-Tagvalue. You could use a-ForEachpattern to reduce code duplication.🔎 Example parameterized approach
BeforeDiscovery { $script:ssrsTestCases = @( @{ Tag = 'Integration_SQL2017_RS'; InstanceName = 'SSRS' } @{ Tag = 'Integration_SQL2019_RS'; InstanceName = 'SSRS' } @{ Tag = 'Integration_SQL2022_RS'; InstanceName = 'SSRS' } ) } Context 'When disabling secure connection for SQL Server Reporting Services' -Tag @($Tag) -ForEach $script:ssrsTestCases { # ... shared test logic using $InstanceName }tests/Unit/Private/Invoke-RsCimMethod.Tests.ps1 (1)
88-98: Remove unused$mockCimInstancefromBeforeAll.The
$mockCimInstancedefined at lines 89-91 is never used becauseInModuleScopecreates its own scope, and the variable is redefined inside eachItblock'sInModuleScopescriptblock.🔎 Suggested fix
Context 'When invoking a CIM method successfully' { BeforeAll { - $mockCimInstance = [PSCustomObject] @{ - InstanceName = 'SSRS' - } - Mock -CommandName Invoke-CimMethod -MockWith { return [PSCustomObject] @{ HRESULT = 0 } } }
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (9)
source/DSCResources/DSC_SqlRS/DSC_SqlRS.psm1source/Public/Disable-SqlDscRsSecureConnection.ps1source/Public/Enable-SqlDscRsSecureConnection.ps1source/Public/Get-SqlDscRSConfiguration.ps1tests/Integration/Commands/Disable-SqlDscRsSecureConnection.Integration.Tests.ps1tests/Integration/Commands/Enable-SqlDscRsSecureConnection.Integration.Tests.ps1tests/Unit/Private/Invoke-RsCimMethod.Tests.ps1tests/Unit/Public/Disable-SqlDscRsSecureConnection.Tests.ps1tests/Unit/Public/Enable-SqlDscRsSecureConnection.Tests.ps1
🚧 Files skipped from review as they are similar to previous changes (6)
- tests/Unit/Public/Disable-SqlDscRsSecureConnection.Tests.ps1
- source/Public/Enable-SqlDscRsSecureConnection.ps1
- tests/Integration/Commands/Enable-SqlDscRsSecureConnection.Integration.Tests.ps1
- source/Public/Get-SqlDscRSConfiguration.ps1
- tests/Unit/Public/Enable-SqlDscRsSecureConnection.Tests.ps1
- source/Public/Disable-SqlDscRsSecureConnection.ps1
🧰 Additional context used
📓 Path-based instructions (12)
**/*.ps1
📄 CodeRabbit inference engine (.github/instructions/SqlServerDsc-guidelines.instructions.md)
**/*.ps1: Format public commands as{Verb}-SqlDsc{Noun}following PowerShell naming conventions
Format private functions as{Verb}-{Noun}following PowerShell naming conventions
Files:
tests/Integration/Commands/Disable-SqlDscRsSecureConnection.Integration.Tests.ps1tests/Unit/Private/Invoke-RsCimMethod.Tests.ps1
**/tests/Integration/**/*.ps1
📄 CodeRabbit inference engine (.github/instructions/SqlServerDsc-guidelines.instructions.md)
Integration tests: use
Connect-SqlDscDatabaseEnginefor SQL Server DB session with correct CI credentials, and always follow withDisconnect-SqlDscDatabaseEngine
Files:
tests/Integration/Commands/Disable-SqlDscRsSecureConnection.Integration.Tests.ps1
**/*.[Tt]ests.ps1
📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines-pester.instructions.md)
**/*.[Tt]ests.ps1: All public commands, private functions and classes must have unit tests
All public commands and class-based resources must have integration tests
Use Pester v5 syntax only
Test code only insideDescribeblocks
Assertions only inItblocks
Never test verbose messages, debug messages or parameter binding behavior
Pass all mandatory parameters to avoid prompts
InsideItblocks, assign unused return objects to$null(unless part of pipeline)
Tested entity must be called from within theItblocks
Keep results and assertions in sameItblock
Avoid try-catch-finally for cleanup, useAfterAllorAfterEach
Avoid unnecessary remove/recreate cycles
OneDescribeblock per file matching the tested entity name
Contextdescriptions start with 'When'
Itdescriptions start with 'Should', must not contain 'when'
Mock variables prefix: 'mock'
Public commands: Never useInModuleScope(unless retrieving localized strings or creating an object using an internal class)
Private functions/class resources: Always useInModuleScope
Each class method = separateContextblock
Each scenario = separateContextblock
Use nestedContextblocks for complex scenarios
Mocking inBeforeAll(BeforeEachonly when required)
Setup/teardown inBeforeAll,BeforeEach/AfterAll,AfterEachclose to usage
Spacing between blocks, arrange, act, and assert for readability
PascalCase:Describe,Context,It,Should,BeforeAll,BeforeEach,AfterAll,AfterEach
Use-BeTrue/-BeFalsenever-Be $true/-Be $false
Never useAssert-MockCalled, useShould -Invokeinstead
NoShould -Not -Throw- invoke commands directly
Never add an empty-MockWithblock
Omit-MockWithwhen returning$null
Set$PSDefaultParameterValuesforMock:ModuleName,Should:ModuleName,InModuleScope:ModuleName
Omit-ModuleNameparameter on Pester commands
Never useMockinsideInModuleScope-block
Never useparam()inside-MockWithscriptblock...
Files:
tests/Integration/Commands/Disable-SqlDscRsSecureConnection.Integration.Tests.ps1tests/Unit/Private/Invoke-RsCimMethod.Tests.ps1
⚙️ CodeRabbit configuration file
**/*.[Tt]ests.ps1: # Tests GuidelinesCore Requirements
- All public commands, private functions and classes must have unit tests
- All public commands and class-based resources must have integration tests
- Use Pester v5 syntax only
- Test code only inside
Describeblocks- Assertions only in
Itblocks- Never test verbose messages, debug messages or parameter binding behavior
- Pass all mandatory parameters to avoid prompts
Requirements
- Inside
Itblocks, assign unused return objects to$null(unless part of pipeline)- Tested entity must be called from within the
Itblocks- Keep results and assertions in same
Itblock- Avoid try-catch-finally for cleanup, use
AfterAllorAfterEach- Avoid unnecessary remove/recreate cycles
Naming
- One
Describeblock per file matching the tested entity nameContextdescriptions start with 'When'Itdescriptions start with 'Should', must not contain 'when'- Mock variables prefix: 'mock'
Structure & Scope
- Public commands: Never use
InModuleScope(unless retrieving localized strings or creating an object using an internal class)- Private functions/class resources: Always use
InModuleScope- Each class method = separate
Contextblock- Each scenario = separate
Contextblock- Use nested
Contextblocks for complex scenarios- Mocking in
BeforeAll(BeforeEachonly when required)- Setup/teardown in
BeforeAll,BeforeEach/AfterAll,AfterEachclose to usage- Spacing between blocks, arrange, act, and assert for readability
Syntax Rules
- PascalCase:
Describe,Context,It,Should,BeforeAll,BeforeEach,AfterAll,AfterEach- Use
-BeTrue/-BeFalsenever-Be $true/-Be $false- Never use
Assert-MockCalled, useShould -Invokeinstead- No
Should -Not -Throw- invoke commands directly- Never add an empty
-MockWithblock- Omit
-MockWithwhen returning$null- Set
$PSDefaultParameterValuesforMock:ModuleName,Should:ModuleName, `...
Files:
tests/Integration/Commands/Disable-SqlDscRsSecureConnection.Integration.Tests.ps1tests/Unit/Private/Invoke-RsCimMethod.Tests.ps1
tests/Integration/Commands/*.Integration.Tests.ps1
📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines.instructions.md)
Integration tests for commands should be located in
tests/Integration/Commands/{CommandName}.Integration.Tests.ps1Location for command integration tests:
tests/Integration/Commands/{CommandName}.Integration.Tests.ps1
Files:
tests/Integration/Commands/Disable-SqlDscRsSecureConnection.Integration.Tests.ps1
**/*.{ps1,psm1,psd1}
📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines-powershell.instructions.md)
**/*.{ps1,psm1,psd1}: Use descriptive names (3+ characters, no abbreviations) for functions, parameters, variables, and classes
Functions: Use PascalCase with Verb-Noun format using approved verbs
Parameters: Use PascalCase naming
Variables: Use camelCase naming
Keywords: Use lower-case
Classes: Use PascalCase naming
Include scope for script/global/environment variables:$script:,$global:,$env:
Use 4 spaces for indentation (no tabs)
Use one space around operators:$a = 1 + 2
Use one space between type and variable:[String] $name
Use one space between keyword and parenthesis:if ($condition)
No spaces on empty lines
Limit lines to 120 characters
Place newline before opening brace (except variable assignments)
Place one newline after opening brace
Place two newlines after closing brace (one if followed by another brace or continuation)
Use single quotes unless variable expansion is needed:'text'vs"text $variable"
For single-line arrays use:@('one', 'two', 'three')
For multi-line arrays: place each element on separate line with proper indentation
Do not use the unary comma operator (,) in return statements to force an array
For empty hashtables use:@{}
For hashtables: place each property on separate line with proper indentation and use PascalCase for property names
Single-line comments: use# Commentformat (capitalized, on own line)
Multi-line comments: use<# Comment #>format (opening and closing brackets on own line with indented text)
No commented-out code
Always add comment-based help to all functions and scripts with SYNOPSIS, DESCRIPTION (40+ chars), PARAMETER, and EXAMPLE sections before function/class
Comment-based help indentation: keywords 4 spaces, text 8 spaces
Include examples in comment-based help for all parameter sets and combinations
INPUTS section in comment-based help: List each pipeline-accepted type as inline code with a 1-line description, repeat keyword for each input type, specifyNone.if there are no inp...
Files:
tests/Integration/Commands/Disable-SqlDscRsSecureConnection.Integration.Tests.ps1tests/Unit/Private/Invoke-RsCimMethod.Tests.ps1source/DSCResources/DSC_SqlRS/DSC_SqlRS.psm1
tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1
📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md)
tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1: Integration tests must use real environment only - no mocking allowed
Integration tests must cover all scenarios and code paths
UseGet-ComputerNamefor computer names in CI environments within integration tests
Avoid usingExpectedMessageparameter forShould -Throwassertions in integration tests
Call commands with-Forceparameter where applicable in integration tests to avoid prompting
Use-ErrorAction 'Stop'on commands in integration tests so failures surface immediately
Integration test files must include the required setup block with SuppressMessageAttribute, BeforeDiscovery block for DscResource.Test module import, and BeforeAll block for module initialization
Files:
tests/Integration/Commands/Disable-SqlDscRsSecureConnection.Integration.Tests.ps1
⚙️ CodeRabbit configuration file
tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1: # Integration Tests GuidelinesRequirements
- Location Commands:
tests/Integration/Commands/{CommandName}.Integration.Tests.ps1- Location Resources:
tests/Integration/Resources/{ResourceName}.Integration.Tests.ps1- No mocking - real environment only
- Cover all scenarios and code paths
- Use
Get-ComputerNamefor computer names in CI- Avoid
ExpectedMessageforShould -Throwassertions- Only run integration tests in CI unless explicitly instructed.
- Call commands with
-Forceparameter where applicable (avoids prompting).- Use
-ErrorAction 'Stop'on commands so failures surface immediatelyRequired Setup Block
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '', Justification = 'Suppressing this rule because Script Analyzer does not understand Pester syntax.')] param () BeforeDiscovery { try { if (-not (Get-Module -Name 'DscResource.Test')) { # Assumes dependencies have been resolved, so if this module is not available, run 'noop' task. if (-not (Get-Module -Name 'DscResource.Test' -ListAvailable)) { # Redirect all streams to $null, except the error stream (stream 2) & "$PSScriptRoot/../../../build.ps1" -Tasks 'noop' 3>&1 4>&1 5>&1 6>&1 > $null } # If the dependencies have not been resolved, this will throw an error. Import-Module -Name 'DscResource.Test' -Force -ErrorAction 'Stop' } } catch [System.IO.FileNotFoundException] { throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -ResolveDependency -Tasks noop" first.' } } BeforeAll { $script:moduleName = '{MyModuleName}' Import-Module -Name $script:moduleName -ErrorAction 'Stop' }
Files:
tests/Integration/Commands/Disable-SqlDscRsSecureConnection.Integration.Tests.ps1
**
⚙️ CodeRabbit configuration file
**: # DSC Community GuidelinesTerminology
- Command: Public command
- Function: Private function
- Resource: DSC class-based resource
Build & Test Workflow Requirements
- Run PowerShell script files from repository root
- Setup build and test environment (once per
pwshsession):./build.ps1 -Tasks noop- Build project before running tests:
./build.ps1 -Tasks build- Always run tests in new
pwshsession:Invoke-Pester -Path @({test paths}) -Output DetailedFile Organization
- Public commands:
source/Public/{CommandName}.ps1- Private functions:
source/Private/{FunctionName}.ps1- Classes:
source/Classes/{DependencyGroupNumber}.{ClassName}.ps1- Enums:
source/Enum/{DependencyGroupNumber}.{EnumName}.ps1- Unit tests:
tests/Unit/{Classes|Public|Private}/{Name}.Tests.ps1- Integration tests:
tests/Integration/Commands/{CommandName}.Integration.Tests.ps1Requirements
- Follow instructions over existing code patterns
- Follow PowerShell style and test guideline instructions strictly
- Always update CHANGELOG.md Unreleased section
- Localize all strings using string keys; remove any orphaned string keys
- Check DscResource.Common before creating private functions
- Separate reusable logic into private functions
- DSC resources should always be created as class-based resources
- Add unit tests for all commands/functions/resources
- Add integration tests for all public commands and resources
Files:
tests/Integration/Commands/Disable-SqlDscRsSecureConnection.Integration.Tests.ps1tests/Unit/Private/Invoke-RsCimMethod.Tests.ps1source/DSCResources/DSC_SqlRS/DSC_SqlRS.psm1
{**/*.ps1,**/*.psm1,**/*.psd1}
⚙️ CodeRabbit configuration file
{**/*.ps1,**/*.psm1,**/*.psd1}: # PowerShell GuidelinesNaming
- Use descriptive names (3+ characters, no abbreviations)
- Functions: PascalCase with Verb-Noun format using approved verbs
- Parameters: PascalCase
- Variables: camelCase
- Keywords: lower-case
- Classes: PascalCase
- Include scope for script/global/environment variables:
$script:,$global:,$env:File naming
- Class files:
###.ClassName.ps1format (e.g.001.SqlReason.ps1,004.StartupParameters.ps1)Formatting
Indentation & Spacing
- Use 4 spaces (no tabs)
- One space around operators:
$a = 1 + 2- One space between type and variable:
[String] $name- One space between keyword and parenthesis:
if ($condition)- No spaces on empty lines
- Try to limit lines to 120 characters
Braces
- Newline before opening brace (except variable assignments)
- One newline after opening brace
- Two newlines after closing brace (one if followed by another brace or continuation)
Quotes
- Use single quotes unless variable expansion is needed:
'text'vs"text $variable"Arrays
- Single line:
@('one', 'two', 'three')- Multi-line: each element on separate line with proper indentation
- Do not use the unary comma operator (
,) in return statements to force
an arrayHashtables
- Empty:
@{}- Each property on separate line with proper indentation
- Properties: Use PascalCase
Comments
- Single line:
# Comment(capitalized, on own line)- Multi-line:
<# Comment #>format (opening and closing brackets on own line), and indent text- No commented-out code
Comment-based help
- Always add comment-based help to all functions and scripts
- Comment-based help: SYNOPSIS, DESCRIPTION (40+ chars), PARAMETER, EXAMPLE sections before function/class
- Comment-based help indentation: keywords 4 spaces, text 8 spaces
- Include examples for all parameter sets and combinations
- INPUTS: List each pipeline‑accepted type as inline code with a 1‑line description...
Files:
tests/Integration/Commands/Disable-SqlDscRsSecureConnection.Integration.Tests.ps1tests/Unit/Private/Invoke-RsCimMethod.Tests.ps1source/DSCResources/DSC_SqlRS/DSC_SqlRS.psm1
tests/Unit/Private/*.[Tt]ests.ps1
📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines-pester.instructions.md)
Private functions:
tests/Unit/Private/{Name}.Tests.ps1
Files:
tests/Unit/Private/Invoke-RsCimMethod.Tests.ps1
tests/Unit/**/*.Tests.ps1
📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines.instructions.md)
Unit tests should be located in
tests/Unit/{Classes|Public|Private}/{Name}.Tests.ps1
Files:
tests/Unit/Private/Invoke-RsCimMethod.Tests.ps1
tests/[Uu]nit/**/*.[Tt]ests.ps1
📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines-unit-tests.instructions.md)
tests/[Uu]nit/**/*.[Tt]ests.ps1: Test with localized strings usingInModuleScope -ScriptBlock { $script:localizedData.Key }in Pester unit tests
Mock files using the$TestDrivevariable (path to the test drive) in Pester unit tests
All public commands require parameter set validation tests in unit tests
Use the exact Pester test setup block withBeforeDiscovery,BeforeAll, andAfterAllblocks beforeDescribein unit tests, includingDscResource.Testmodule import and PSDefaultParameterValues configuration
Use parameter set validation test template withGet-CommandandParameterSetsproperty, supporting both single and multiple parameter sets via-ForEacharray in Pester unit tests
Use parameter properties test template withGet-Commandto validate individual parameter attributes (e.g., Mandatory flag) in Pester unit tests
Files:
tests/Unit/Private/Invoke-RsCimMethod.Tests.ps1
⚙️ CodeRabbit configuration file
tests/[Uu]nit/**/*.[Tt]ests.ps1: # Unit Tests Guidelines
- Test with localized strings: Use
InModuleScope -ScriptBlock { $script:localizedData.Key }- Mock files: Use
$TestDrivevariable (path to the test drive)- All public commands require parameter set validation tests
- After modifying classes, always run tests in new session (for changes to take effect)
Test Setup Requirements
Use this exact setup block before
Describe:[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '', Justification = 'Suppressing this rule because Script Analyzer does not understand Pester syntax.')] param () BeforeDiscovery { try { if (-not (Get-Module -Name 'DscResource.Test')) { # Assumes dependencies have been resolved, so if this module is not available, run 'noop' task. if (-not (Get-Module -Name 'DscResource.Test' -ListAvailable)) { # Redirect all streams to $null, except the error stream (stream 2) & "$PSScriptRoot/../../../build.ps1" -Tasks 'noop' 3>&1 4>&1 5>&1 6>&1 > $null } # If the dependencies have not been resolved, this will throw an error. Import-Module -Name 'DscResource.Test' -Force -ErrorAction 'Stop' } } catch [System.IO.FileNotFoundException] { throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -ResolveDependency -Tasks noop" first.' } } BeforeAll { $script:moduleName = '{MyModuleName}' Import-Module -Name $script:moduleName -ErrorAction 'Stop' $PSDefaultParameterValues['InModuleScope:ModuleName'] = $script:moduleName $PSDefaultParameterValues['Mock:ModuleName'] = $script:moduleName $PSDefaultParameterValues['Should:ModuleName'] = $script:moduleName } AfterAll { $PSDefaultParameterValues.Remove('InModuleScope:ModuleName') $PSDefaultParameterValues.Remove('Mock:ModuleName') ...
Files:
tests/Unit/Private/Invoke-RsCimMethod.Tests.ps1
source/DSCResources/**/*.psm1
📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md)
source/DSCResources/**/*.psm1: Every DSC resource must define the three required functions:Get-TargetResource,Set-TargetResource, andTest-TargetResource
Export functions using the*-TargetResourcepattern
Get-TargetResourcefunction must return a hashtable with all resource properties
Test-TargetResourcefunction must return a boolean value ($true or $false)
Set-TargetResourcefunction must not return anything (void)
Get-TargetResourceshould only include parameters needed to retrieve actual current state values
Get-TargetResourceshould remove non-mandatory parameters that are never used
Set-TargetResourceandTest-TargetResourcemust have identical parameters
Unused mandatory parameters inSet-TargetResourceandTest-TargetResourceshould include "Not used in <function_name>" in the help comment
Each DSC resource function must include at least oneWrite-Verbosestatement
Get-TargetResourceverbose messages must start with "Getting the current state of..."
Set-TargetResourceverbose messages must start with "Setting the desired state of..."
Test-TargetResourceverbose messages must start with "Determining the current state of..."
Use localized strings for all messages including Write-Verbose, Write-Error, and other messaging commands
Import localized strings usingGet-LocalizedDataat the module top level
Usetry/catchblocks to handle exceptions in MOF-based DSC resources
UseNew-InvalidDataExceptionfor invalid data errors instead ofthrowin MOF-based DSC resources
UseNew-ArgumentExceptionfor argument-related errors instead ofthrowin MOF-based DSC resources
UseNew-InvalidOperationExceptionfor invalid operation errors instead ofthrowin MOF-based DSC resources
UseNew-ObjectNotFoundExceptionfor object not found errors instead ofthrowin MOF-based DSC resources
UseNew-InvalidResultExceptionfor invalid result errors instead ofthrowin MOF-based DSC resources
UseNew-NotImplementedException...
Files:
source/DSCResources/DSC_SqlRS/DSC_SqlRS.psm1
⚙️ CodeRabbit configuration file
source/DSCResources/**/*.psm1: # MOF-based Desired State Configuration (DSC) Resources GuidelinesRequired Functions
- Every DSC resource must define:
Get-TargetResource,Set-TargetResource,Test-TargetResource- Export using
*-TargetResourcepatternFunction Return Types
Get-TargetResource: Must return hashtable with all resource propertiesTest-TargetResource: Must return boolean ($true/$false)Set-TargetResource: Must not return anything (void)Parameter Guidelines
Get-TargetResource: Only include parameters needed to retrieve actual current state valuesGet-TargetResource: Remove non-mandatory parameters that are never usedSet-TargetResourceandTest-TargetResource: Must have identical parametersSet-TargetResourceandTest-TargetResource: Unused mandatory parameters: Add "Not used in <function_name>" to help commentRequired Elements
- Each function must include
Write-Verboseat least once
Get-TargetResource: Use verbose message starting with "Getting the current state of..."Set-TargetResource: Use verbose message starting with "Setting the desired state of..."Test-TargetResource: Use verbose message starting with "Determining the current state of..."- Use localized strings for all messages (Write-Verbose, Write-Error, etc.)
- Import localized strings using
Get-LocalizedDataat module topError Handling
- Do not use
throwfor terminating errors- Use
try/catchblocks to handle exceptions- Throw localized exceptions using the appropriate
New-*Exceptioncmdlet:
New‑InvalidDataExceptionNew-ArgumentExceptionNew-InvalidOperationException- [
New-ObjectNotFoundException](https:/...
Files:
source/DSCResources/DSC_SqlRS/DSC_SqlRS.psm1
🧠 Learnings (31)
📓 Common learnings
Learnt from: dan-hughes
Repo: dsccommunity/UpdateServicesDsc PR: 85
File: source/en-US/UpdateServicesDsc.strings.psd1:1-2
Timestamp: 2025-10-04T21:33:23.022Z
Learning: In UpdateServicesDsc (and similar DSC modules), the module-level localization file (source/en-US/<ModuleName>.strings.psd1) can be empty when DSC resources have their own localization files in source/DSCResources/<ResourceName>/en-US/DSC_<ResourceName>.strings.psd1. Automated tests verify localization completeness for resources. Don't flag empty module-level localization files as issues when resources have separate localization.
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 2367
File: source/en-US/SqlServerDsc.strings.psd1:489-498
Timestamp: 2025-12-10T20:07:45.822Z
Learning: In SqlServerDsc (and DSC Community modules), localization string error codes may have gaps in their sequential numbering (e.g., RSDD0001, RSDD0003) when strings are removed over time. Never suggest renumbering localization keys to make them sequential. QA tests safeguard against missing or extra localization string keys.
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-11-27T17:58:02.422Z
Learning: Applies to **/tests/Integration/**/*.ps1 : Integration tests: use `Connect-SqlDscDatabaseEngine` for SQL Server DB session with correct CI credentials, and always follow with `Disconnect-SqlDscDatabaseEngine`
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-11-27T17:58:02.422Z
Learning: Applies to **/tests/**/*.tests.ps1 : Add `$env:SqlServerDscCI = $true` in `BeforeAll` block and remove in `AfterAll` block of unit tests
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-11-27T17:59:01.508Z
Learning: Applies to source/DSCResources/**/*.psm1 : Use localized strings for all messages including Write-Verbose, Write-Error, and other messaging commands
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-11-27T17:58:02.422Z
Learning: Applies to **/resources/**/*.ps1 : Add `InstanceName`, `ServerName`, and `Credential` to `$this.ExcludeDscProperties` in Database Engine resources
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-11-27T17:58:02.422Z
Learning: Applies to **/*.ps1 : Format public commands as `{Verb}-SqlDsc{Noun}` following PowerShell naming conventions
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-11-27T17:59:01.508Z
Learning: Applies to source/DSCResources/**/*.psm1 : Use names returned from `Get-UICulture` for additional language folder names in DSC resources
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-11-27T17:59:01.508Z
Learning: Applies to source/DSCResources/**/*.psm1 : Import localized strings using `Get-LocalizedData` at the module top level
Learnt from: Borgquite
Repo: dsccommunity/UpdateServicesDsc PR: 78
File: source/DSCResources/MSFT_UpdateServicesComputerTargetGroup/MSFT_UpdateServicesComputerTargetGroup.psm1:9-22
Timestamp: 2025-10-03T15:27:24.417Z
Learning: In the UpdateServicesDsc repository, MOF-based DSC resources follow a minimal comment-based help convention that includes only .SYNOPSIS and .PARAMETER sections. The .DESCRIPTION, .INPUTS, and .OUTPUTS sections are intentionally omitted, even though functions have [OutputType()] attributes. This is consistent across all existing DSC resources: MSFT_UpdateServicesServer, MSFT_UpdateServicesCleanup, and MSFT_UpdateServicesApprovalRule.
📚 Learning: 2025-11-27T17:58:02.422Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-11-27T17:58:02.422Z
Learning: Applies to **/tests/Integration/**/*.ps1 : Integration tests: use `Connect-SqlDscDatabaseEngine` for SQL Server DB session with correct CI credentials, and always follow with `Disconnect-SqlDscDatabaseEngine`
Applied to files:
tests/Integration/Commands/Disable-SqlDscRsSecureConnection.Integration.Tests.ps1
📚 Learning: 2025-12-30T15:15:25.261Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-12-30T15:15:25.261Z
Learning: Applies to tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1 : Integration test files must include the required setup block with SuppressMessageAttribute, BeforeDiscovery block for DscResource.Test module import, and BeforeAll block for module initialization
Applied to files:
tests/Integration/Commands/Disable-SqlDscRsSecureConnection.Integration.Tests.ps1tests/Unit/Private/Invoke-RsCimMethod.Tests.ps1
📚 Learning: 2025-11-27T17:58:02.422Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-11-27T17:58:02.422Z
Learning: Applies to **/tests/**/*.tests.ps1 : Add `$env:SqlServerDscCI = $true` in `BeforeAll` block and remove in `AfterAll` block of unit tests
Applied to files:
tests/Integration/Commands/Disable-SqlDscRsSecureConnection.Integration.Tests.ps1tests/Unit/Private/Invoke-RsCimMethod.Tests.ps1
📚 Learning: 2025-12-30T15:15:25.261Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-12-30T15:15:25.261Z
Learning: Applies to tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1 : Call commands with `-Force` parameter where applicable in integration tests to avoid prompting
Applied to files:
tests/Integration/Commands/Disable-SqlDscRsSecureConnection.Integration.Tests.ps1
📚 Learning: 2025-12-30T15:15:36.079Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-unit-tests.instructions.md:0-0
Timestamp: 2025-12-30T15:15:36.079Z
Learning: Applies to tests/[Uu]nit/**/*.[Tt]ests.ps1 : Use the exact Pester test setup block with `BeforeDiscovery`, `BeforeAll`, and `AfterAll` blocks before `Describe` in unit tests, including `DscResource.Test` module import and PSDefaultParameterValues configuration
Applied to files:
tests/Integration/Commands/Disable-SqlDscRsSecureConnection.Integration.Tests.ps1tests/Unit/Private/Invoke-RsCimMethod.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to **/*.[Tt]ests.ps1 : All public commands and class-based resources must have integration tests
Applied to files:
tests/Integration/Commands/Disable-SqlDscRsSecureConnection.Integration.Tests.ps1tests/Unit/Private/Invoke-RsCimMethod.Tests.ps1
📚 Learning: 2025-12-30T15:15:25.261Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-12-30T15:15:25.261Z
Learning: Applies to tests/Integration/Resources/*.Integration.Tests.ps1 : Location for resource integration tests: `tests/Integration/Resources/{ResourceName}.Integration.Tests.ps1`
Applied to files:
tests/Integration/Commands/Disable-SqlDscRsSecureConnection.Integration.Tests.ps1
📚 Learning: 2025-10-12T12:10:48.625Z
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 2303
File: tests/Integration/Commands/PostInstallationConfiguration.Integration.Tests.ps1:127-143
Timestamp: 2025-10-12T12:10:48.625Z
Learning: For the SqlServerDsc module integration tests, ForceEncryption should not be enabled on the SQL Server instance (DSCSQLTEST) because the module needs to test both encrypted and non-encrypted connection scenarios in CI.
Applied to files:
tests/Integration/Commands/Disable-SqlDscRsSecureConnection.Integration.Tests.ps1source/DSCResources/DSC_SqlRS/DSC_SqlRS.psm1
📚 Learning: 2025-12-30T15:15:25.261Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-12-30T15:15:25.261Z
Learning: Applies to tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1 : Integration tests must cover all scenarios and code paths
Applied to files:
tests/Integration/Commands/Disable-SqlDscRsSecureConnection.Integration.Tests.ps1
📚 Learning: 2025-11-27T18:00:35.078Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines.instructions.md:0-0
Timestamp: 2025-11-27T18:00:35.078Z
Learning: Applies to tests/Integration/Commands/*.Integration.Tests.ps1 : Integration tests for commands should be located in `tests/Integration/Commands/{CommandName}.Integration.Tests.ps1`
Applied to files:
tests/Integration/Commands/Disable-SqlDscRsSecureConnection.Integration.Tests.ps1
📚 Learning: 2025-11-27T18:56:46.759Z
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 1622
File: tests/Integration/DSC_SqlDatabase.Integration.Tests.ps1:1-30
Timestamp: 2025-11-27T18:56:46.759Z
Learning: Integration tests for MOF-based DSC resources (located in source/DSCResources/**) should use the Initialize-TestEnvironment pattern with -ResourceType 'Mof', not the BeforeDiscovery/BeforeAll pattern. The BeforeDiscovery/BeforeAll pattern is for class-based resources only.
Applied to files:
tests/Integration/Commands/Disable-SqlDscRsSecureConnection.Integration.Tests.ps1tests/Unit/Private/Invoke-RsCimMethod.Tests.ps1
📚 Learning: 2025-08-10T15:11:52.897Z
Learnt from: dan-hughes
Repo: dsccommunity/ActiveDirectoryDsc PR: 741
File: azure-pipelines.yml:104-104
Timestamp: 2025-08-10T15:11:52.897Z
Learning: In the ActiveDirectoryDsc project, HQRM (High Quality Resource Module) tests must run in PowerShell 5 (Windows PowerShell) using `pwsh: false` in the Azure Pipelines configuration, while unit tests can run in PowerShell 7 (PowerShell Core) with `pwsh: true`. This differentiation is intentional due to HQRM's specific requirements and dependencies on Windows PowerShell.
Applied to files:
tests/Integration/Commands/Disable-SqlDscRsSecureConnection.Integration.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to **/*.[Tt]ests.ps1 : Mocking in `BeforeAll` (`BeforeEach` only when required)
Applied to files:
tests/Integration/Commands/Disable-SqlDscRsSecureConnection.Integration.Tests.ps1
📚 Learning: 2025-11-27T17:59:01.508Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-11-27T17:59:01.508Z
Learning: Applies to source/DSCResources/**/*.psm1 : `Test-TargetResource` function must return a boolean value ($true or $false)
Applied to files:
tests/Integration/Commands/Disable-SqlDscRsSecureConnection.Integration.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to tests/Unit/Private/*.[Tt]ests.ps1 : Private functions: `tests/Unit/Private/{Name}.Tests.ps1`
Applied to files:
tests/Unit/Private/Invoke-RsCimMethod.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to **/*.[Tt]ests.ps1 : All public commands, private functions and classes must have unit tests
Applied to files:
tests/Unit/Private/Invoke-RsCimMethod.Tests.ps1
📚 Learning: 2025-11-27T17:58:02.422Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-11-27T17:58:02.422Z
Learning: Applies to **/tests/**/*.tests.ps1 : When unit tests test classes or commands containing SMO types like `[Microsoft.SqlServer.Management.Smo.*]`, ensure they are properly stubbed in SMO.cs
Applied to files:
tests/Unit/Private/Invoke-RsCimMethod.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to **/*.[Tt]ests.ps1 : Use Pester v5 syntax only
Applied to files:
tests/Unit/Private/Invoke-RsCimMethod.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to **/*.[Tt]ests.ps1 : Cover all scenarios and code paths
Applied to files:
tests/Unit/Private/Invoke-RsCimMethod.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to **/*.[Tt]ests.ps1 : Each class method = separate `Context` block
Applied to files:
tests/Unit/Private/Invoke-RsCimMethod.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to **/*.[Tt]ests.ps1 : Never use `Assert-MockCalled`, use `Should -Invoke` instead
Applied to files:
tests/Unit/Private/Invoke-RsCimMethod.Tests.ps1
📚 Learning: 2025-11-27T17:58:20.404Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-class-resource.instructions.md:0-0
Timestamp: 2025-11-27T17:58:20.404Z
Learning: Applies to source/[cC]lasses/**/*.ps1 : DSC class-based resources must implement required methods: `Get()`, `Test()`, `Set()`, `GetCurrentState()`, and `Modify()` following the specified pattern
Applied to files:
tests/Unit/Private/Invoke-RsCimMethod.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to **/*.[Tt]ests.ps1 : Never use `Mock` inside `InModuleScope`-block
Applied to files:
tests/Unit/Private/Invoke-RsCimMethod.Tests.ps1
📚 Learning: 2025-08-17T10:15:48.194Z
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 2136
File: tests/Unit/Public/Remove-SqlDscLogin.Tests.ps1:36-39
Timestamp: 2025-08-17T10:15:48.194Z
Learning: Public command unit tests guideline: Never use InModuleScope unless accessing localized strings from $script:localizedData. PSDefaultParameterValues for InModuleScope should be kept in public command tests to support localized string retrieval when necessary.
Applied to files:
tests/Unit/Private/Invoke-RsCimMethod.Tests.ps1
📚 Learning: 2025-10-10T14:01:42.703Z
Learnt from: dan-hughes
Repo: dsccommunity/UpdateServicesDsc PR: 86
File: tests/Unit/MSFT_UpdateServicesServer.Tests.ps1:6-45
Timestamp: 2025-10-10T14:01:42.703Z
Learning: For script-based (MOF) DSC resources in UpdateServicesDsc, unit tests should use Initialize-TestEnvironment with variables $script:dscModuleName and $script:dscResourceName, and set -ResourceType 'Mof'. This differs from class-based resource tests which use the simpler $script:moduleName template without Initialize-TestEnvironment.
Applied to files:
tests/Unit/Private/Invoke-RsCimMethod.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to **/*.[Tt]ests.ps1 : Private functions/class resources: Always use `InModuleScope`
Applied to files:
tests/Unit/Private/Invoke-RsCimMethod.Tests.ps1
📚 Learning: 2025-11-27T17:59:01.508Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-11-27T17:59:01.508Z
Learning: Applies to source/DSCResources/**/*.psm1 : `Set-TargetResource` function must not return anything (void)
Applied to files:
source/DSCResources/DSC_SqlRS/DSC_SqlRS.psm1
📚 Learning: 2025-11-27T17:59:01.508Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-11-27T17:59:01.508Z
Learning: Applies to source/DSCResources/**/*.psm1 : `Set-TargetResource` verbose messages must start with "Setting the desired state of..."
Applied to files:
source/DSCResources/DSC_SqlRS/DSC_SqlRS.psm1
📚 Learning: 2025-11-27T17:59:01.508Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-11-27T17:59:01.508Z
Learning: Applies to source/DSCResources/**/*.psm1 : `Set-TargetResource` and `Test-TargetResource` must have identical parameters
Applied to files:
source/DSCResources/DSC_SqlRS/DSC_SqlRS.psm1
📚 Learning: 2025-11-27T17:59:01.508Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-11-27T17:59:01.508Z
Learning: Applies to source/DSCResources/**/*.psm1 : Unused mandatory parameters in `Set-TargetResource` and `Test-TargetResource` should include "Not used in <function_name>" in the help comment
Applied to files:
source/DSCResources/DSC_SqlRS/DSC_SqlRS.psm1
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: dsccommunity.SqlServerDsc (Build Package Module)
- GitHub Check: PSScriptAnalyzer
- GitHub Check: PSScriptAnalyzer
🔇 Additional comments (8)
source/DSCResources/DSC_SqlRS/DSC_SqlRS.psm1 (2)
607-614: LGTM! Clean refactoring to use the new public TLS commands.The delegation to
Enable-SqlDscRsSecureConnectionandDisable-SqlDscRsSecureConnectionwith-Forceis appropriate for a DSC resource context where prompting should be suppressed. The pipeline input from$reportingServicesData.Configurationis correctly used.
827-834: Consistent with the initialization branch.The TLS toggle logic mirrors the pattern used in lines 607-614, maintaining consistency within
Set-TargetResource.tests/Integration/Commands/Disable-SqlDscRsSecureConnection.Integration.Tests.ps1 (3)
1-32: Setup block follows integration test guidelines.The BeforeDiscovery block correctly handles DscResource.Test dependency resolution, and BeforeAll imports the module without
-Forceto preserve CIM type identities. This is the correct pattern for integration tests.
35-79: Good test structure with proper state restoration.The pattern of capturing original state in
BeforeAlland restoring inAfterAllensures tests don't leave side effects. The test logic correctly enables TLS first before testing the disable operation.
173-218: PBIRS context correctly tests Power BI Report Server.The test properly uses the 'PBIRS' instance name and follows the same pattern as SSRS tests. The
cSpell: ignore PBIRScomment is helpful for spell-checking tools.tests/Unit/Private/Invoke-RsCimMethod.Tests.ps1 (3)
1-84: Well-structured unit test setup for private function.The setup correctly:
- Handles DscResource.Test dependency
- Sets
$env:SqlServerDscCIper coding guidelines- Creates a stub for
Invoke-CimMethodfor cross-platform compatibility- Configures
$PSDefaultParameterValuesfor Pester commands- Uses
InModuleScopeappropriately for private function testing
135-178: Good coverage of error scenarios.The tests properly verify both
ExtendedErrorsandErrorproperty error paths, ensuring the function throws with the appropriate error information including method name and HRESULT.
180-205: Comprehensive test for complex return types.This test verifies that the function correctly returns the full CIM method result including array properties, which is essential for methods like
ListReservedUrlsthat return multiple values.
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 3
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
source/Public/Get-SqlDscRSConfiguration.ps1
🧰 Additional context used
📓 Path-based instructions (6)
source/**/*.ps1
📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines-localization.instructions.md)
source/**/*.ps1: Localize all Write-Debug, Write-Verbose, Write-Error, Write-Warning and $PSCmdlet.ThrowTerminatingError() messages in PowerShell scripts
Use localized string keys from $script:localizedData, not hardcoded strings, in diagnostic messages
Reference localized strings using the syntax: Write-Verbose -Message ($script:localizedData.KeyName -f $value1)Localize all strings using string keys; remove any orphaned string keys
Files:
source/Public/Get-SqlDscRSConfiguration.ps1
⚙️ CodeRabbit configuration file
source/**/*.ps1: # Localization GuidelinesRequirements
- Localize all Write-Debug, Write-Verbose, Write-Error, Write-Warning and $PSCmdlet.ThrowTerminatingError() messages
- Use localized string keys, not hardcoded strings
- Assume
$script:localizedDatais availableString Files
- Commands/functions:
source/en-US/{MyModuleName}.strings.psd1- Class resources:
source/en-US/{ResourceClassName}.strings.psd1Key Naming Patterns
- Format:
Verb_FunctionName_Action(underscore separators), e.g.Get_Database_ConnectingToDatabaseString Format
ConvertFrom-StringData @' KeyName = Message with {0} placeholder. (PREFIX0001) '@String IDs
- Format:
(PREFIX####)- PREFIX: First letter of each word in class or function name (SqlSetup → SS, Get-SqlDscDatabase → GSDD)
- Number: Sequential from 0001
Usage
Write-Verbose -Message ($script:localizedData.KeyName -f $value1)
Files:
source/Public/Get-SqlDscRSConfiguration.ps1
source/Public/*.ps1
📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines.instructions.md)
Public commands should be located in
source/Public/{CommandName}.ps1
Files:
source/Public/Get-SqlDscRSConfiguration.ps1
**/*.{ps1,psm1,psd1}
📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines-powershell.instructions.md)
**/*.{ps1,psm1,psd1}: Use descriptive names (3+ characters, no abbreviations) for functions, parameters, variables, and classes
Functions: Use PascalCase with Verb-Noun format using approved verbs
Parameters: Use PascalCase naming
Variables: Use camelCase naming
Keywords: Use lower-case
Classes: Use PascalCase naming
Include scope for script/global/environment variables:$script:,$global:,$env:
Use 4 spaces for indentation (no tabs)
Use one space around operators:$a = 1 + 2
Use one space between type and variable:[String] $name
Use one space between keyword and parenthesis:if ($condition)
No spaces on empty lines
Limit lines to 120 characters
Place newline before opening brace (except variable assignments)
Place one newline after opening brace
Place two newlines after closing brace (one if followed by another brace or continuation)
Use single quotes unless variable expansion is needed:'text'vs"text $variable"
For single-line arrays use:@('one', 'two', 'three')
For multi-line arrays: place each element on separate line with proper indentation
Do not use the unary comma operator (,) in return statements to force an array
For empty hashtables use:@{}
For hashtables: place each property on separate line with proper indentation and use PascalCase for property names
Single-line comments: use# Commentformat (capitalized, on own line)
Multi-line comments: use<# Comment #>format (opening and closing brackets on own line with indented text)
No commented-out code
Always add comment-based help to all functions and scripts with SYNOPSIS, DESCRIPTION (40+ chars), PARAMETER, and EXAMPLE sections before function/class
Comment-based help indentation: keywords 4 spaces, text 8 spaces
Include examples in comment-based help for all parameter sets and combinations
INPUTS section in comment-based help: List each pipeline-accepted type as inline code with a 1-line description, repeat keyword for each input type, specifyNone.if there are no inp...
Files:
source/Public/Get-SqlDscRSConfiguration.ps1
**/Public/**/*.ps1
📄 CodeRabbit inference engine (.github/instructions/SqlServerDsc-guidelines.instructions.md)
Public commands must follow the naming format
{Verb}-SqlDsc{Noun}
Files:
source/Public/Get-SqlDscRSConfiguration.ps1
**
⚙️ CodeRabbit configuration file
**: # DSC Community GuidelinesTerminology
- Command: Public command
- Function: Private function
- Resource: DSC class-based resource
Build & Test Workflow Requirements
- Run PowerShell script files from repository root
- Setup build and test environment (once per
pwshsession):./build.ps1 -Tasks noop- Build project before running tests:
./build.ps1 -Tasks build- Always run tests in new
pwshsession:Invoke-Pester -Path @({test paths}) -Output DetailedFile Organization
- Public commands:
source/Public/{CommandName}.ps1- Private functions:
source/Private/{FunctionName}.ps1- Classes:
source/Classes/{DependencyGroupNumber}.{ClassName}.ps1- Enums:
source/Enum/{DependencyGroupNumber}.{EnumName}.ps1- Unit tests:
tests/Unit/{Classes|Public|Private}/{Name}.Tests.ps1- Integration tests:
tests/Integration/Commands/{CommandName}.Integration.Tests.ps1Requirements
- Follow instructions over existing code patterns
- Follow PowerShell style and test guideline instructions strictly
- Always update CHANGELOG.md Unreleased section
- Localize all strings using string keys; remove any orphaned string keys
- Check DscResource.Common before creating private functions
- Separate reusable logic into private functions
- DSC resources should always be created as class-based resources
- Add unit tests for all commands/functions/resources
- Add integration tests for all public commands and resources
Files:
source/Public/Get-SqlDscRSConfiguration.ps1
{**/*.ps1,**/*.psm1,**/*.psd1}
⚙️ CodeRabbit configuration file
{**/*.ps1,**/*.psm1,**/*.psd1}: # PowerShell GuidelinesNaming
- Use descriptive names (3+ characters, no abbreviations)
- Functions: PascalCase with Verb-Noun format using approved verbs
- Parameters: PascalCase
- Variables: camelCase
- Keywords: lower-case
- Classes: PascalCase
- Include scope for script/global/environment variables:
$script:,$global:,$env:File naming
- Class files:
###.ClassName.ps1format (e.g.001.SqlReason.ps1,004.StartupParameters.ps1)Formatting
Indentation & Spacing
- Use 4 spaces (no tabs)
- One space around operators:
$a = 1 + 2- One space between type and variable:
[String] $name- One space between keyword and parenthesis:
if ($condition)- No spaces on empty lines
- Try to limit lines to 120 characters
Braces
- Newline before opening brace (except variable assignments)
- One newline after opening brace
- Two newlines after closing brace (one if followed by another brace or continuation)
Quotes
- Use single quotes unless variable expansion is needed:
'text'vs"text $variable"Arrays
- Single line:
@('one', 'two', 'three')- Multi-line: each element on separate line with proper indentation
- Do not use the unary comma operator (
,) in return statements to force
an arrayHashtables
- Empty:
@{}- Each property on separate line with proper indentation
- Properties: Use PascalCase
Comments
- Single line:
# Comment(capitalized, on own line)- Multi-line:
<# Comment #>format (opening and closing brackets on own line), and indent text- No commented-out code
Comment-based help
- Always add comment-based help to all functions and scripts
- Comment-based help: SYNOPSIS, DESCRIPTION (40+ chars), PARAMETER, EXAMPLE sections before function/class
- Comment-based help indentation: keywords 4 spaces, text 8 spaces
- Include examples for all parameter sets and combinations
- INPUTS: List each pipeline‑accepted type as inline code with a 1‑line description...
Files:
source/Public/Get-SqlDscRSConfiguration.ps1
🧠 Learnings (2)
📓 Common learnings
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 2367
File: source/en-US/SqlServerDsc.strings.psd1:489-498
Timestamp: 2025-12-10T20:07:45.822Z
Learning: In SqlServerDsc (and DSC Community modules), localization string error codes may have gaps in their sequential numbering (e.g., RSDD0001, RSDD0003) when strings are removed over time. Never suggest renumbering localization keys to make them sequential. QA tests safeguard against missing or extra localization string keys.
Learnt from: dan-hughes
Repo: dsccommunity/UpdateServicesDsc PR: 85
File: source/en-US/UpdateServicesDsc.strings.psd1:1-2
Timestamp: 2025-10-04T21:33:23.022Z
Learning: In UpdateServicesDsc (and similar DSC modules), the module-level localization file (source/en-US/<ModuleName>.strings.psd1) can be empty when DSC resources have their own localization files in source/DSCResources/<ResourceName>/en-US/DSC_<ResourceName>.strings.psd1. Automated tests verify localization completeness for resources. Don't flag empty module-level localization files as issues when resources have separate localization.
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2026-01-01T11:57:15.286Z
Learning: Applies to **/tests/Unit/**/*.ps1 : Unit tests must add `$env:SqlServerDscCI = $true` in `BeforeAll` block and remove in `AfterAll` block
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2026-01-01T11:57:15.286Z
Learning: Applies to **/tests/Integration/**/*.ps1 : Integration tests must use `Connect-SqlDscDatabaseEngine` for SQL Server DB session with correct CI credentials
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-11-27T17:59:01.508Z
Learning: Applies to source/DSCResources/**/*.psm1 : Import localized strings using `Get-LocalizedData` at the module top level
📚 Learning: 2026-01-01T11:57:15.286Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2026-01-01T11:57:15.286Z
Learning: Applies to **/Public/**/*.ps1 : Public commands must follow the naming format `{Verb}-SqlDsc{Noun}`
Applied to files:
source/Public/Get-SqlDscRSConfiguration.ps1
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (30)
- GitHub Check: dsccommunity.SqlServerDsc (Integration Test Commands - Reporting Services Commands SQL2022_WIN2025)
- GitHub Check: dsccommunity.SqlServerDsc (Integration Test Commands - Reporting Services Commands SQL2022_WIN2022)
- GitHub Check: dsccommunity.SqlServerDsc (Integration Test Commands - Reporting Services Commands SQL2019_WIN2025)
- GitHub Check: dsccommunity.SqlServerDsc (Integration Test Commands - Reporting Services Commands SQL2019_WIN2022)
- GitHub Check: dsccommunity.SqlServerDsc (Integration Test Commands - Reporting Services Commands SQL2017_WIN2022)
- GitHub Check: dsccommunity.SqlServerDsc (Integration Test Commands - BI Report Server Commands PowerBI_WIN2025)
- GitHub Check: dsccommunity.SqlServerDsc (Integration Test Commands - BI Report Server Commands PowerBI_WIN2022)
- GitHub Check: dsccommunity.SqlServerDsc (Integration Test Commands - SQL Server Commands SQL2019_WIN2022)
- GitHub Check: dsccommunity.SqlServerDsc (Integration Test Commands - SQL Server (Prepared Image) Commands - Prepared Image SQL2022_WIN2025)
- GitHub Check: dsccommunity.SqlServerDsc (Integration Test Commands - SQL Server Commands SQL2022_WIN2025)
- GitHub Check: dsccommunity.SqlServerDsc (Integration Test Resources - SQL Server Integration SQL2022_WIN2025)
- GitHub Check: dsccommunity.SqlServerDsc (Integration Test Commands - SQL Server (Prepared Image) Commands - Prepared Image SQL2022_WIN2022)
- GitHub Check: dsccommunity.SqlServerDsc (Integration Test Commands - SQL Server Commands SQL2022_WIN2022)
- GitHub Check: dsccommunity.SqlServerDsc (Integration Test Resources - SQL Server Integration SQL2022_WIN2022)
- GitHub Check: dsccommunity.SqlServerDsc (Integration Test Commands - SQL Server (Prepared Image) Commands - Prepared Image SQL2019_WIN2025)
- GitHub Check: dsccommunity.SqlServerDsc (Integration Test Commands - SQL Server Commands SQL2019_WIN2025)
- GitHub Check: dsccommunity.SqlServerDsc (Integration Test Resources - SQL Server Integration SQL2019_WIN2025)
- GitHub Check: dsccommunity.SqlServerDsc (Integration Test Commands - SQL Server Commands SQL2019_WIN2022)
- GitHub Check: dsccommunity.SqlServerDsc (Integration Test Commands - SQL Server (Prepared Image) Commands - Prepared Image SQL2019_WIN2022)
- GitHub Check: dsccommunity.SqlServerDsc (Integration Test Resources - SQL Server Integration SQL2019_WIN2022)
- GitHub Check: dsccommunity.SqlServerDsc (Integration Test Commands - SQL Server (Prepared Image) Commands - Prepared Image SQL2017_WIN2022)
- GitHub Check: dsccommunity.SqlServerDsc (Integration Test Commands - SQL Server Commands SQL2017_WIN2022)
- GitHub Check: dsccommunity.SqlServerDsc (Integration Test Resources - SQL Server Integration SQL2017_WIN2022)
- GitHub Check: dsccommunity.SqlServerDsc (Integration Test Resources - Power BI Report Server Integration PowerBI_WIN2025)
- GitHub Check: dsccommunity.SqlServerDsc (Integration Test Resources - Power BI Report Server Integration PowerBI_WIN2022)
- GitHub Check: dsccommunity.SqlServerDsc (Quality Test and Unit Test Publish Code Coverage)
- GitHub Check: dsccommunity.SqlServerDsc (Quality Test and Unit Test Unit)
- GitHub Check: dsccommunity.SqlServerDsc (Quality Test and Unit Test HQRM)
- GitHub Check: dsccommunity.SqlServerDsc (Quality Test and Unit Test Determine DSC Resource Test Requirements)
- GitHub Check: dsccommunity.SqlServerDsc (Build Package Module)
🔇 Additional comments (2)
source/Public/Get-SqlDscRSConfiguration.ps1 (2)
52-66: LGTM!Function declaration follows naming conventions, includes proper
[CmdletBinding()]and[OutputType()]attributes, and parameters are correctly structured.
68-93: LGTM!Version detection logic correctly uses
New-ErrorRecordandNew-InvalidOperationExceptionhelper functions for error handling, and properly uses localized strings for verbose messages.
…Record for improved clarity
johlju
left a comment
There was a problem hiding this comment.
@johlju partially reviewed 16 files and all commit messages, made 1 comment, and resolved 4 discussions.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @johlju).
Pull Request (PR) description
Get-SqlDscRSConfigurationto retrieve theMSReportServer_ConfigurationSettingCIM instance for SQL Server ReportingServices or Power BI Report Server. Supports auto-detection of the Reporting
Services version or explicit version specification. The returned CIM instance
can be piped to
Enable-SqlDscRsSecureConnectionorDisable-SqlDscRsSecureConnection(issue #2022).
Enable-SqlDscRsSecureConnectionto enable secureconnection for SQL Server Reporting Services or Power BI Report Server by
setting the secure connection level to 1. Accepts the configuration CIM
instance from pipeline, supports
-WhatIf/-Confirm, and-PassThrutoreturn the configuration object
(issue #2022).
Disable-SqlDscRsSecureConnectionto disable secureconnection for SQL Server Reporting Services or Power BI Report Server by
setting the secure connection level to 0. Accepts the configuration CIM
instance from pipeline, supports
-WhatIf/-Confirm, and-PassThrutoreturn the configuration object
(issue #2023).
Invoke-RsCimMethodto invoke CIM methods on ReportingServices configuration instances with consistent error handling. This function
is used by
Enable-SqlDscRsSecureConnection,Disable-SqlDscRsSecureConnection,and the
SqlRSresource.SqlRSEnable-SqlDscRsSecureConnectionandDisable-SqlDscRsSecureConnectionfor setting the secure connection levelinstead of calling the CIM method directly.
This Pull Request (PR) fixes the following issues
Task list
file CHANGELOG.md. Entry should say what was changed and how that
affects users (if applicable), and reference the issue being resolved
(if applicable).
This change is