Skip to content

Add functions to enable and disable TLS for Reporting Services#2387

Merged
johlju merged 14 commits intodsccommunity:mainfrom
johlju:f/issue-#2022-and-#2023
Jan 1, 2026
Merged

Add functions to enable and disable TLS for Reporting Services#2387
johlju merged 14 commits intodsccommunity:mainfrom
johlju:f/issue-#2022-and-#2023

Conversation

@johlju
Copy link
Copy Markdown
Member

@johlju johlju commented Dec 31, 2025

Pull Request (PR) description

  • Added public command Get-SqlDscRSConfiguration to retrieve the
    MSReportServer_ConfigurationSetting CIM instance for SQL Server Reporting
    Services 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-SqlDscRsSecureConnection or Disable-SqlDscRsSecureConnection
    (issue #2022).
  • Added public command Enable-SqlDscRsSecureConnection to enable secure
    connection 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 -PassThru to
    return the configuration object
    (issue #2022).
  • Added public command Disable-SqlDscRsSecureConnection to disable secure
    connection 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 -PassThru to
    return the configuration object
    (issue #2023).
  • Added private function Invoke-RsCimMethod to invoke CIM methods on Reporting
    Services configuration instances with consistent error handling. This function
    is used by Enable-SqlDscRsSecureConnection, Disable-SqlDscRsSecureConnection,
    and the SqlRS resource.
  • SqlRS
    • Refactored to use the public commands Enable-SqlDscRsSecureConnection and
      Disable-SqlDscRsSecureConnection for setting the secure connection level
      instead of calling the CIM method directly.

This Pull Request (PR) fixes the following issues

Task list

  • Added an entry to the change log under the Unreleased section of the
    file CHANGELOG.md. Entry should say what was changed and how that
    affects users (if applicable), and reference the issue being resolved
    (if applicable).
  • Resource documentation updated in the resource's README.md.
  • Resource parameter descriptions updated in schema.mof.
  • Comment-based help updated, including parameter descriptions.
  • Localization strings updated.
  • Examples updated.
  • Unit tests updated. See DSC Community Testing Guidelines.
  • Integration tests updated (where possible). See DSC Community Testing Guidelines.
  • Code changes adheres to DSC Community Style Guidelines.

This change is Reviewable

@johlju johlju requested a review from a team as a code owner December 31, 2025 17:42
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Dec 31, 2025

Walkthrough

Adds 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

Cohort / File(s) Summary
Public — RS Configuration
source/Public/Get-SqlDscRSConfiguration.ps1, tests/Unit/Public/Get-SqlDscRSConfiguration.Tests.ps1, tests/Integration/Commands/Get-SqlDscRSConfiguration.Integration.Tests.ps1
New exported cmdlet to return MSReportServer_ConfigurationSetting CIM instances; auto-detects version via Get-SqlDscRSSetupConfiguration when omitted; adds unit and integration tests validating versions and output type.
Public — TLS Management
source/Public/Enable-SqlDscRsSecureConnection.ps1, source/Public/Disable-SqlDscRsSecureConnection.ps1, tests/Unit/Public/Enable-SqlDscRsSecureConnection.Tests.ps1, tests/Unit/Public/Disable-SqlDscRsSecureConnection.Tests.ps1, tests/Integration/Commands/Enable-SqlDscRsSecureConnection.Integration.Tests.ps1, tests/Integration/Commands/Disable-SqlDscRsSecureConnection.Integration.Tests.ps1
Two new pipeline-accepting cmdlets that call SetSecureConnectionLevel on a configuration CIM; implement ShouldProcess, -Force, -PassThru, aliases, verbose/messages, structured terminating errors; full unit and integration coverage.
Private Helper
source/Private/Invoke-RsCimMethod.ps1, tests/Unit/Private/Invoke-RsCimMethod.Tests.ps1
New wrapper around Invoke-CimMethod centralizing parameter construction, HRESULT / ExtendedErrors / Error aggregation, and uniform terminating errors; unit tests cover success/failure variants.
DSC Resource Update
source/DSCResources/DSC_SqlRS/DSC_SqlRS.psm1, tests/Unit/DSC_SqlRS.Tests.ps1
Replaced direct CIM method invocations of SetSecureConnectionLevel with calls to Enable-SqlDscRsSecureConnection -Force / Disable-SqlDscRsSecureConnection -Force in Set-TargetResource; tests updated to mock/expect new cmdlets.
Localization
source/en-US/SqlServerDsc.strings.psd1
Added localized strings for Get-SqlDscRSConfiguration, Enable-SqlDscRsSecureConnection, Disable-SqlDscRsSecureConnection, and Invoke-RsCimMethod (ShouldProcess text and error messages).
CI & Tests Integration
azure-pipelines.yml, tests/Integration/... (new files listed above)
Added the three new RS command integration tests into multiple PesterPath groups/stages in the pipeline to execute integration suites.
Changelog / Public Surface
CHANGELOG.md
Documents new public commands (Get-SqlDscRSConfiguration, Enable-SqlDscRsSecureConnection, Disable-SqlDscRsSecureConnection, Get-SqlDscServerProtocolTcpIp), private helper Invoke-RsCimMethod, and removal of Assert-SetupActionProperties from exported surface.

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
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Pre-merge checks

✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The PR title clearly summarizes the main change: adding functions to enable and disable TLS for Reporting Services, which is the primary objective of the PR.
Description check ✅ Passed The PR description is well-related to the changeset, detailing the three public commands added, the private helper function, the SqlRS refactoring, and linking to the relevant issues.
Linked Issues check ✅ Passed The PR successfully implements the objectives from issues #2022 and #2023: Enable-SqlDscRsSecureConnection and Disable-SqlDscRsSecureConnection commands that call SetSecureConnectionLevel with appropriate parameters.
Out of Scope Changes check ✅ Passed All code changes are directly related to implementing the TLS enable/disable functionality and refactoring SqlRS to use these new commands; no out-of-scope changes detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b4633c7 and 110c600.

📒 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 Guidelines

Requirements

  • Localize all Write-Debug, Write-Verbose, Write-Error, Write-Warning and $PSCmdlet.ThrowTerminatingError() messages
  • Use localized string keys, not hardcoded strings
  • Assume $script:localizedData is available

String Files

  • Commands/functions: source/en-US/{MyModuleName}.strings.psd1
  • Class resources: source/en-US/{ResourceClassName}.strings.psd1

Key Naming Patterns

  • Format: Verb_FunctionName_Action (underscore separators), e.g. Get_Database_ConnectingToDatabase

String 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 # Comment format (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, specify None. 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 Guidelines

Terminology

  • 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 pwsh session): ./build.ps1 -Tasks noop
  • Build project before running tests: ./build.ps1 -Tasks build
  • Always run tests in new pwsh session: Invoke-Pester -Path @({test paths}) -Output Detailed

File 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.ps1

Requirements

  • 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 Guidelines

Naming

  • 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.ps1 format (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 array

Hashtables

  • 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 (16)
📓 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: 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/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: 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
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
📚 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
📚 Learning: 2025-10-03T15:27:24.417Z
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.

Applied to files:

  • source/Public/Get-SqlDscRSConfiguration.ps1
📚 Learning: 2025-12-10T20:07:45.822Z
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.

Applied to files:

  • source/Public/Get-SqlDscRSConfiguration.ps1
📚 Learning: 2025-12-24T18:09:36.332Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-12-24T18:09:36.332Z
Learning: Applies to **/*.{ps1,psm1,psd1} : For error handling, use `New-ErrorRecord` instead of `[System.Management.Automation.ErrorRecord]::new(...)`

Applied to files:

  • source/Public/Get-SqlDscRSConfiguration.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 : Use `New-InvalidOperationException` for invalid operation errors instead of `throw` in MOF-based DSC resources

Applied to files:

  • source/Public/Get-SqlDscRSConfiguration.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 use `New-*Exception` commands (such as `New-InvalidDataException`, `New-ArgumentException`, `New-InvalidOperationException`, `New-ObjectNotFoundException`, `New-InvalidResultException`, `New-NotImplementedException`) instead of `throw` for terminating errors in classes

Applied to files:

  • source/Public/Get-SqlDscRSConfiguration.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 : Use `New-InvalidDataException` for invalid data errors instead of `throw` in MOF-based DSC resources

Applied to files:

  • source/Public/Get-SqlDscRSConfiguration.ps1
📚 Learning: 2025-12-24T18:09:36.332Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-12-24T18:09:36.332Z
Learning: Applies to **/*.{ps1,psm1,psd1} : Use `$PSCmdlet.ThrowTerminatingError()` for terminating errors (except for classes), use relevant error category, in try-catch include exception with localized message

Applied to files:

  • source/Public/Get-SqlDscRSConfiguration.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 : Use `New-InvalidResultException` for invalid result errors instead of `throw` in MOF-based DSC resources

Applied to files:

  • source/Public/Get-SqlDscRSConfiguration.ps1
📚 Learning: 2025-12-24T18:09:36.332Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-12-24T18:09:36.332Z
Learning: Applies to **/*.{ps1,psm1,psd1} : For error handling, use `New-Exception` instead of `[System.Exception]::new(...)`

Applied to files:

  • source/Public/Get-SqlDscRSConfiguration.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 : Use `try/catch` blocks to handle exceptions in MOF-based DSC resources

Applied to files:

  • source/Public/Get-SqlDscRSConfiguration.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 : Use `New-NotImplementedException` for not implemented errors instead of `throw` in MOF-based DSC resources

Applied to files:

  • source/Public/Get-SqlDscRSConfiguration.ps1
📚 Learning: 2025-12-24T18:09:36.332Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-12-24T18:09:36.332Z
Learning: Applies to **/*.{ps1,psm1,psd1} : In catch blocks with `Write-Error`, pass original exception using `-Exception` and always use `return` after `Write-Error` to avoid further processing

Applied to files:

  • source/Public/Get-SqlDscRSConfiguration.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 : Use `New-ArgumentException` for argument-related errors instead of `throw` in MOF-based DSC resources

Applied to files:

  • source/Public/Get-SqlDscRSConfiguration.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 : Use `New-ObjectNotFoundException` for object not found errors instead of `throw` in MOF-based DSC resources

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). (3)
  • GitHub Check: dsccommunity.SqlServerDsc (Build Package Module)
  • GitHub Check: PSScriptAnalyzer
  • GitHub Check: PSScriptAnalyzer
🔇 Additional comments (5)
source/Public/Get-SqlDscRSConfiguration.ps1 (5)

1-51: Comment-based help is well-structured.

The help section includes all required elements: SYNOPSIS, DESCRIPTION (>40 chars), PARAMETER sections, multiple EXAMPLES covering different use cases, INPUTS, and OUTPUTS with proper type documentation.

Regarding the past review comment about command names: The PR summary confirms the actual command names are Enable-SqlDscRsSecureConnection and Disable-SqlDscRsSecureConnection, so the documentation appears correct.


52-66: LGTM!

Function declaration follows all coding guidelines: proper naming convention (Get-SqlDsc{Noun}), [CmdletBinding()], [OutputType()], mandatory/optional parameter attributes, and correct formatting.


68-93: LGTM!

Version auto-detection logic is well-implemented:

  • Properly checks $PSBoundParameters for optional parameter
  • Uses localized strings for verbose messages
  • Error handling correctly uses New-ErrorRecord and New-InvalidOperationException helper functions
  • Appropriate error categories (ObjectNotFound) and unique error IDs

95-114: LGTM!

CIM retrieval logic follows best practices:

  • Uses splatting for Get-CimInstance parameters
  • Wraps in try/catch with proper error handling
  • Preserves original exception context using -ErrorRecord $_
  • Uses correct helper functions for error record creation

116-132: LGTM!

Post-fetch filtering and return logic is correct:

  • Filters results to match the exact instance name
  • Proper error handling if configuration not found
  • Uses return statement as per guidelines

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@johlju johlju added the needs review The pull request needs a code review. label Dec 31, 2025
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 -ModuleName parameter per PSDefaultParameterValues.

The -ModuleName parameter is explicitly specified but PSDefaultParameterValues already sets it. Per guidelines, omit -ModuleName on 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 separately

The SqlRS change description correctly states the switch to Enable-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.

Comment thread source/Public/Disable-SqlDscRSTls.ps1 Outdated
Comment thread source/Public/Disable-SqlDscRSTls.ps1 Fixed
Comment thread source/Public/Disable-SqlDscRSTls.ps1 Fixed
Comment thread source/Public/Enable-SqlDscRSTls.ps1 Fixed
Comment thread source/Public/Enable-SqlDscRSTls.ps1 Fixed
@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 31, 2025

Codecov Report

❌ Patch coverage is 97.67442% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 94%. Comparing base (b6ddc10) to head (110c600).
⚠️ Report is 35 commits behind head on main.

Files with missing lines Patch % Lines
source/DSCResources/DSC_SqlRS/DSC_SqlRS.psm1 66% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@          Coverage Diff          @@
##            main   #2387   +/-   ##
=====================================
  Coverage     94%     94%           
=====================================
  Files        174     178    +4     
  Lines      10157   10231   +74     
=====================================
+ Hits        9556    9628   +72     
- Misses       601     603    +2     
Flag Coverage Δ
unit 94% <97%> (+<1%) ⬆️
Files with missing lines Coverage Δ
source/Private/Invoke-RsCimMethod.ps1 100% <100%> (ø)
source/Public/Disable-SqlDscRsSecureConnection.ps1 100% <100%> (ø)
source/Public/Enable-SqlDscRsSecureConnection.ps1 100% <100%> (ø)
source/Public/Get-SqlDscRSConfiguration.ps1 100% <100%> (ø)
source/DSCResources/DSC_SqlRS/DSC_SqlRS.psm1 97% <66%> (-1%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

… 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.
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (8)
source/Public/Get-SqlDscRSConfiguration.ps1 (1)

78-85: Consider using New-ErrorRecord helper for error handling.

Per coding guidelines, use New-ErrorRecord instead 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-SqlDscRsSecureConnection and Disable-SqlDscRsSecureConnection, but the already-initialized path (lines 821-836) still uses Invoke-RsCimMethod directly with SetSecureConnectionLevel. 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 adding PassThru tests for SQL2019 and SQL2022 contexts.

The SQL2017 and Power BI contexts include a PassThru test 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 adding PassThru tests to these contexts as well.

Also applies to: 114-145

tests/Integration/Commands/Enable-SqlDscRsSecureConnection.Integration.Tests.ps1 (1)

76-107: Consider adding PassThru tests for SQL2019 and SQL2022 contexts.

Similar to the Disable tests, the SQL2019 and SQL2022 contexts are missing PassThru tests 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-Command pattern:

🔎 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 using New-ErrorRecord helper for error handling.

Per coding guidelines, error handling should use New-ErrorRecord instead of direct [System.Management.Automation.ErrorRecord]::new(...) construction. The New-ErrorRecord and New-Exception helpers 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 using New-ErrorRecord helper for error handling.

Per coding guidelines, error handling should use New-ErrorRecord instead of direct [System.Management.Automation.ErrorRecord]::new(...) construction. Same recommendation as the Disable-SqlDscRsSecureConnection function.

🔎 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)
             }

Comment thread tests/Unit/DSC_SqlRS.Tests.ps1
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 -Tag value. You could use a -ForEach pattern 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 $mockCimInstance from BeforeAll.

The $mockCimInstance defined at lines 89-91 is never used because InModuleScope creates its own scope, and the variable is redefined inside each It block's InModuleScope scriptblock.

🔎 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

📥 Commits

Reviewing files that changed from the base of the PR and between 727011a and f27f342.

📒 Files selected for processing (9)
  • source/DSCResources/DSC_SqlRS/DSC_SqlRS.psm1
  • source/Public/Disable-SqlDscRsSecureConnection.ps1
  • source/Public/Enable-SqlDscRsSecureConnection.ps1
  • source/Public/Get-SqlDscRSConfiguration.ps1
  • tests/Integration/Commands/Disable-SqlDscRsSecureConnection.Integration.Tests.ps1
  • tests/Integration/Commands/Enable-SqlDscRsSecureConnection.Integration.Tests.ps1
  • tests/Unit/Private/Invoke-RsCimMethod.Tests.ps1
  • tests/Unit/Public/Disable-SqlDscRsSecureConnection.Tests.ps1
  • tests/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.ps1
  • tests/Unit/Private/Invoke-RsCimMethod.Tests.ps1
**/tests/Integration/**/*.ps1

📄 CodeRabbit inference engine (.github/instructions/SqlServerDsc-guidelines.instructions.md)

Integration tests: use Connect-SqlDscDatabaseEngine for SQL Server DB session with correct CI credentials, and always follow with Disconnect-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 inside Describe blocks
Assertions only in It blocks
Never test verbose messages, debug messages or parameter binding behavior
Pass all mandatory parameters to avoid prompts
Inside It blocks, assign unused return objects to $null (unless part of pipeline)
Tested entity must be called from within the It blocks
Keep results and assertions in same It block
Avoid try-catch-finally for cleanup, use AfterAll or AfterEach
Avoid unnecessary remove/recreate cycles
One Describe block per file matching the tested entity name
Context descriptions start with 'When'
It descriptions start with 'Should', must not contain 'when'
Mock variables prefix: 'mock'
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 Context block
Each scenario = separate Context block
Use nested Context blocks for complex scenarios
Mocking in BeforeAll (BeforeEach only when required)
Setup/teardown in BeforeAll,BeforeEach/AfterAll,AfterEach close to usage
Spacing between blocks, arrange, act, and assert for readability
PascalCase: Describe, Context, It, Should, BeforeAll, BeforeEach, AfterAll, AfterEach
Use -BeTrue/-BeFalse never -Be $true/-Be $false
Never use Assert-MockCalled, use Should -Invoke instead
No Should -Not -Throw - invoke commands directly
Never add an empty -MockWith block
Omit -MockWith when returning $null
Set $PSDefaultParameterValues for Mock:ModuleName, Should:ModuleName, InModuleScope:ModuleName
Omit -ModuleName parameter on Pester commands
Never use Mock inside InModuleScope-block
Never use param() inside -MockWith scriptblock...

Files:

  • tests/Integration/Commands/Disable-SqlDscRsSecureConnection.Integration.Tests.ps1
  • tests/Unit/Private/Invoke-RsCimMethod.Tests.ps1

⚙️ CodeRabbit configuration file

**/*.[Tt]ests.ps1: # Tests Guidelines

Core 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 Describe blocks
  • Assertions only in It blocks
  • Never test verbose messages, debug messages or parameter binding behavior
  • Pass all mandatory parameters to avoid prompts

Requirements

  • Inside It blocks, assign unused return objects to $null (unless part of pipeline)
  • Tested entity must be called from within the It blocks
  • Keep results and assertions in same It block
  • Avoid try-catch-finally for cleanup, use AfterAll or AfterEach
  • Avoid unnecessary remove/recreate cycles

Naming

  • One Describe block per file matching the tested entity name
  • Context descriptions start with 'When'
  • It descriptions 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 Context block
  • Each scenario = separate Context block
  • Use nested Context blocks for complex scenarios
  • Mocking in BeforeAll (BeforeEach only when required)
  • Setup/teardown in BeforeAll,BeforeEach/AfterAll,AfterEach close to usage
  • Spacing between blocks, arrange, act, and assert for readability

Syntax Rules

  • PascalCase: Describe, Context, It, Should, BeforeAll, BeforeEach, AfterAll, AfterEach
  • Use -BeTrue/-BeFalse never -Be $true/-Be $false
  • Never use Assert-MockCalled, use Should -Invoke instead
  • No Should -Not -Throw - invoke commands directly
  • Never add an empty -MockWith block
  • Omit -MockWith when returning $null
  • Set $PSDefaultParameterValues for Mock:ModuleName, Should:ModuleName, `...

Files:

  • tests/Integration/Commands/Disable-SqlDscRsSecureConnection.Integration.Tests.ps1
  • tests/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.ps1

Location 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 # Comment format (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, specify None. if there are no inp...

Files:

  • tests/Integration/Commands/Disable-SqlDscRsSecureConnection.Integration.Tests.ps1
  • tests/Unit/Private/Invoke-RsCimMethod.Tests.ps1
  • source/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
Use Get-ComputerName for computer names in CI environments within integration tests
Avoid using ExpectedMessage parameter for Should -Throw assertions in integration tests
Call commands with -Force parameter 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 Guidelines

Requirements

  • 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-ComputerName for computer names in CI
  • Avoid ExpectedMessage for Should -Throw assertions
  • Only run integration tests in CI unless explicitly instructed.
  • Call commands with -Force parameter where applicable (avoids prompting).
  • Use -ErrorAction 'Stop' on commands so failures surface immediately

Required 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 Guidelines

Terminology

  • 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 pwsh session): ./build.ps1 -Tasks noop
  • Build project before running tests: ./build.ps1 -Tasks build
  • Always run tests in new pwsh session: Invoke-Pester -Path @({test paths}) -Output Detailed

File 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.ps1

Requirements

  • 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.ps1
  • tests/Unit/Private/Invoke-RsCimMethod.Tests.ps1
  • source/DSCResources/DSC_SqlRS/DSC_SqlRS.psm1
{**/*.ps1,**/*.psm1,**/*.psd1}

⚙️ CodeRabbit configuration file

{**/*.ps1,**/*.psm1,**/*.psd1}: # PowerShell Guidelines

Naming

  • 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.ps1 format (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 array

Hashtables

  • 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.ps1
  • tests/Unit/Private/Invoke-RsCimMethod.Tests.ps1
  • source/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 using InModuleScope -ScriptBlock { $script:localizedData.Key } in Pester unit tests
Mock files using the $TestDrive variable (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 with BeforeDiscovery, BeforeAll, and AfterAll blocks before Describe in unit tests, including DscResource.Test module import and PSDefaultParameterValues configuration
Use parameter set validation test template with Get-Command and ParameterSets property, supporting both single and multiple parameter sets via -ForEach array in Pester unit tests
Use parameter properties test template with Get-Command to 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 $TestDrive variable (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, and Test-TargetResource
Export functions using the *-TargetResource pattern
Get-TargetResource function must return a hashtable with all resource properties
Test-TargetResource function must return a boolean value ($true or $false)
Set-TargetResource function must not return anything (void)
Get-TargetResource should only include parameters needed to retrieve actual current state values
Get-TargetResource should remove non-mandatory parameters that are never used
Set-TargetResource and Test-TargetResource must have identical parameters
Unused mandatory parameters in Set-TargetResource and Test-TargetResource should include "Not used in <function_name>" in the help comment
Each DSC resource function must include at least one Write-Verbose statement
Get-TargetResource verbose messages must start with "Getting the current state of..."
Set-TargetResource verbose messages must start with "Setting the desired state of..."
Test-TargetResource verbose 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 using Get-LocalizedData at the module top level
Use try/catch blocks to handle exceptions in MOF-based DSC resources
Use New-InvalidDataException for invalid data errors instead of throw in MOF-based DSC resources
Use New-ArgumentException for argument-related errors instead of throw in MOF-based DSC resources
Use New-InvalidOperationException for invalid operation errors instead of throw in MOF-based DSC resources
Use New-ObjectNotFoundException for object not found errors instead of throw in MOF-based DSC resources
Use New-InvalidResultException for invalid result errors instead of throw in MOF-based DSC resources
Use New-NotImplementedException...

Files:

  • source/DSCResources/DSC_SqlRS/DSC_SqlRS.psm1

⚙️ CodeRabbit configuration file

source/DSCResources/**/*.psm1: # MOF-based Desired State Configuration (DSC) Resources Guidelines

Required Functions

  • Every DSC resource must define: Get-TargetResource, Set-TargetResource, Test-TargetResource
  • Export using *-TargetResource pattern

Function Return Types

  • Get-TargetResource: Must return hashtable with all resource properties
  • Test-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 values
  • Get-TargetResource: Remove non-mandatory parameters that are never used
  • Set-TargetResource and Test-TargetResource: Must have identical parameters
  • Set-TargetResource and Test-TargetResource: Unused mandatory parameters: Add "Not used in <function_name>" to help comment

Required Elements

  • Each function must include Write-Verbose at 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-LocalizedData at module top

Error Handling

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.ps1
  • 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 : 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.ps1
  • tests/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.ps1
  • 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 and class-based resources must have integration tests

Applied to files:

  • tests/Integration/Commands/Disable-SqlDscRsSecureConnection.Integration.Tests.ps1
  • tests/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.ps1
  • source/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.ps1
  • tests/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-SqlDscRsSecureConnection and Disable-SqlDscRsSecureConnection with -Force is appropriate for a DSC resource context where prompting should be suppressed. The pipeline input from $reportingServicesData.Configuration is 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 -Force to 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 BeforeAll and restoring in AfterAll ensures 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 PBIRS comment 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:SqlServerDscCI per coding guidelines
  • Creates a stub for Invoke-CimMethod for cross-platform compatibility
  • Configures $PSDefaultParameterValues for Pester commands
  • Uses InModuleScope appropriately for private function testing

135-178: Good coverage of error scenarios.

The tests properly verify both ExtendedErrors and Error property 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 ListReservedUrls that return multiple values.

@johlju
Copy link
Copy Markdown
Member Author

johlju commented Jan 1, 2026

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jan 1, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1bf0705 and b4633c7.

📒 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 Guidelines

Requirements

  • Localize all Write-Debug, Write-Verbose, Write-Error, Write-Warning and $PSCmdlet.ThrowTerminatingError() messages
  • Use localized string keys, not hardcoded strings
  • Assume $script:localizedData is available

String Files

  • Commands/functions: source/en-US/{MyModuleName}.strings.psd1
  • Class resources: source/en-US/{ResourceClassName}.strings.psd1

Key Naming Patterns

  • Format: Verb_FunctionName_Action (underscore separators), e.g. Get_Database_ConnectingToDatabase

String 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 # Comment format (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, specify None. 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 Guidelines

Terminology

  • 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 pwsh session): ./build.ps1 -Tasks noop
  • Build project before running tests: ./build.ps1 -Tasks build
  • Always run tests in new pwsh session: Invoke-Pester -Path @({test paths}) -Output Detailed

File 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.ps1

Requirements

  • 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 Guidelines

Naming

  • 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.ps1 format (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 array

Hashtables

  • 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-ErrorRecord and New-InvalidOperationException helper functions for error handling, and properly uses localized strings for verbose messages.

Comment thread source/Public/Get-SqlDscRSConfiguration.ps1
Comment thread source/Public/Get-SqlDscRSConfiguration.ps1 Outdated
Comment thread source/Public/Get-SqlDscRSConfiguration.ps1 Outdated
Copy link
Copy Markdown
Member Author

@johlju johlju left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

@johlju partially reviewed 16 files and all commit messages, made 1 comment, and resolved 4 discussions.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @johlju).

@johlju johlju merged commit 35a84eb into dsccommunity:main Jan 1, 2026
49 checks passed
@johlju johlju deleted the f/issue-#2022-and-#2023 branch January 1, 2026 19:06
@johlju johlju removed the needs review The pull request needs a code review. label Jan 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Disable-SqlDscReportServerTls: New command proposal Enable-SqlDscReportServerTls: New command proposal

2 participants