Skip to content

Conversation

@johlju
Copy link
Member

@johlju johlju commented Jan 10, 2026

Pull Request (PR) description

This Pull Request (PR) fixes the following issues

None.

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

@coderabbitai
Copy link

coderabbitai bot commented Jan 10, 2026

Caution

Review failed

The pull request is closed.

Walkthrough

Adds Reporting Services public commands and a ReportServerUri class for RS URL/config/log retrieval and encryption-key/encrypted-information management, plus many unit/integration tests, localization strings, CI test publishing, and a rewritten RS service-account wiki workflow.

Changes

Cohort / File(s) Summary
New RS Types & Commands
source/Classes/002.ReportServerUri.ps1, source/Public/Get-SqlDscRSUrl.ps1, source/Public/Get-SqlDscRSConfigFile.ps1, source/Public/Get-SqlDscRSLogPath.ps1
Added ReportServerUri class; new commands to discover Report Server URLs, read RsReportServer.config (XmlDocument) via ByInstanceName/ByConfiguration/ByPath, and retrieve RS log path.
Encryption Key Management Commands
source/Public/New-SqlDscRSEncryptionKey.ps1, source/Public/Remove-SqlDscRSEncryptionKey.ps1, source/Public/Remove-SqlDscRSEncryptedInformation.ps1
New public wrappers around RS CIM methods to delete/regenerate encryption key and remove encrypted information (includes DeleteEncryptedContent/DeleteEncryptedInformation modes).
Parameter Standardization
source/Public/Get-SqlDscRSWebPortalApplicationName.ps1
Pipeline parameter renamed from -Configuration to -SetupConfiguration and internal usage updated.
Localization
source/en-US/SqlServerDsc.strings.psd1
Added string keys for new commands and updated RS-related error key signatures.
Documentation / Wiki
source/WikiSource/Change-Report-Server-Service-Account.md, source/WikiSource/Troubleshooting-Report-Server.md
Reworked service-account workflow with SQL Server 2017-specific path, switched many invocations to parameter-hashtable style, and added log-file guidance.
CI / Pipeline
azure-pipelines.yml
Publish QA tests as NUnit XML and added new integration tests to multiple pipeline stages.
Integration Tests
tests/Integration/Commands/Get-SqlDscRSUrl.Integration.Tests.ps1, tests/Integration/Commands/Get-SqlDscRSConfigFile.Integration.Tests.ps1, tests/Integration/Commands/Post.DatabaseConnection.RS.Integration.Tests.ps1, tests/Integration/Commands/Post.*.RS.Integration.Tests.ps1, tests/Integration/Commands/Remove-SqlDscRSEncryptedInformation.Integration.Tests.ps1
Added integration coverage for URL/config retrieval, encrypted-info/encryption-key flows, DB connection restore for SQL2017, and expanded RS test tagging.
Unit Tests
tests/Unit/Public/Get-SqlDscRSConfigFile.Tests.ps1, tests/Unit/Public/Get-SqlDscRSUrl.Tests.ps1, tests/Unit/Public/Get-SqlDscRSWebPortalApplicationName.Tests.ps1, tests/Unit/Public/Request-SqlDscRSDatabaseRightsScript.Tests.ps1
Added/updated unit tests with parameter-set validation, XML parsing assertions, CIM/method mocks, error-path checks, and parameter rename coverage.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant Module as Get-SqlDscRSUrl
  participant Setup as Get-SqlDscRSSetupConfiguration
  participant CIM as MSReportServer_Instance
  participant Invoker as Invoke-RsCimMethod

  User->>Module: Call Get-SqlDscRSUrl (SetupConfiguration or piped Instance)
  Module->>Setup: (if InstanceName) resolve setup configuration
  Setup-->>Module: returns SetupConfiguration (InstanceId, CurrentVersion)
  Module->>CIM: Get-CimInstance MSReportServer_Instance (namespace from version, filter InstanceId)
  CIM-->>Module: returns instance (or error)
  Module->>Invoker: Invoke GetReportServerUrls on instance
  Invoker-->>Module: returns applications + URLs (or error)
  Module-->>User: emit array of ReportServerUri objects
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title mentions 'integration tests for RS Service Account' but the changeset includes extensive additions of new RS-related public commands and classes beyond just service account tests. Clarify whether the title should reflect the broader scope of RS improvements (new public commands, encryption key management, config file retrieval) or whether 'Improve integration tests for RS Service Account' is the primary focus.
✅ Passed checks (2 passed)
Check name Status Explanation
Description check ✅ Passed The description mentions CHANGELOG.md updates, integration tests updates, and code style adherence, which align with the observable changes across multiple test files, command additions, and documentation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


📜 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 4fac04d and 9d3410d.

📒 Files selected for processing (2)
  • source/WikiSource/Troubleshooting-Report-Server.md
  • tests/Unit/Public/Get-SqlDscRSConfigFile.Tests.ps1

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.

@codecov
Copy link

codecov bot commented Jan 10, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94%. Comparing base (f9c6fd6) to head (4fac04d).

Additional details and impacted files

Impacted file tree graph

@@          Coverage Diff          @@
##            main   #2404   +/-   ##
=====================================
  Coverage     94%     94%           
=====================================
  Files        206     208    +2     
  Lines      10581   10654   +73     
=====================================
+ Hits        9966   10039   +73     
  Misses       615     615           
Flag Coverage Δ
unit 94% <100%> (+<1%) ⬆️
Files with missing lines Coverage Δ
source/Public/Get-SqlDscRSConfigFile.ps1 100% <100%> (ø)
source/Public/Get-SqlDscRSUrl.ps1 100% <100%> (ø)
...ce/Public/Get-SqlDscRSWebPortalApplicationName.ps1 100% <100%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

…module

- Introduced integration tests for Get-SqlDscRSUrl to validate Report Server URLs for SQL Server Reporting Services and Power BI Report Server.
- Added unit tests for Get-SqlDscRSConfigFile to ensure correct XML configuration file retrieval and validation.
- Updated Post.DatabaseConnection and Post.ServiceAccountChange tests to remove unnecessary comments and clarify execution order.
- Refactored Get-SqlDscRSWebPortalApplicationName tests to use SetupConfiguration parameter instead of Configuration.
- Removed TODO comments regarding SQL Server 2017 encryption key validation failures in Post.Reinitialize and Post.ServiceAccountChange tests.
@johlju johlju marked this pull request as ready for review January 10, 2026 11:10
@johlju johlju requested a review from a team as a code owner January 10, 2026 11:10
Copy link

@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: 5

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
tests/Integration/Commands/Post.Reinitialize.RS.Integration.Tests.ps1 (1)

47-70: Tag expansion for SQL 2017 looks good; consider assigning Initialize output to $null.
To align with the test guidelines (“assign unused return objects to $null”), even if the command currently returns nothing.

Proposed tweak
 It 'Should re-initialize the Reporting Services instance' {
-    $script:configuration | Initialize-SqlDscRS -Force -ErrorAction 'Stop'
+    $null = $script:configuration | Initialize-SqlDscRS -Force -ErrorAction 'Stop'
 }
🤖 Fix all issues with AI agents
In @CHANGELOG.md:
- Around line 241-246: The changelog entry that starts "Updated wiki article
`Change-Report-Server-Service-Account` with SQL Server 2017 specific
workflow..." is categorized under the wrong heading; move that bullet from the
"### Added" section into the "### Changed" section of CHANGELOG.md so it follows
Keep a Changelog conventions, ensuring formatting and surrounding list
punctuation remain consistent.

In @source/Public/Get-SqlDscRSConfigFile.ps1:
- Around line 1-15: The DESCRIPTION block in the help comment for
Get-SqlDscRSConfigFile.ps1 still refers to the `Configuration` parameter but the
actual parameter is named `SetupConfiguration`; update the help text to use
`SetupConfiguration` everywhere (e.g., change "`Configuration` parameters" to
"`SetupConfiguration` parameter" and any other occurrences) so the documentation
matches the function signature and remove any remaining references to
`Configuration`.
- Around line 192-208: The Get-SqlDscRSConfigFile function currently uses
Get-Content without -Raw and casts directly to [xml], which can produce string[]
and allow unsafe external entity resolution; change to read the file as a single
string with Get-Content -Raw on $configFilePath and parse it with a hardened XML
parser: create XmlReaderSettings with DtdProcessing set to Prohibit (or Ignore)
and XmlResolver set to $null, then use [System.Xml.XmlReader]::Create over the
raw string and load into an [xml] or XmlDocument instance inside the existing
try/catch so you still build the same $errorMessage and throw the same
terminating error on failure.

In @source/Public/Get-SqlDscRSUrl.ps1:
- Around line 55-86: Get-SqlDscRSUrl currently casts
$SetupConfiguration.CurrentVersion to [System.Version] directly which will throw
an unlocalized runtime error for invalid formats; before the cast, validate the
string (e.g. use [System.Version]::TryParse or wrap the cast in try/catch) and
if parsing fails create the same localized New-InvalidOperationException and
New-ErrorRecord (matching the existing pattern and error id 'GSRSU0001') and
call $PSCmdlet.ThrowTerminatingError so callers receive a localized, controlled
error; only set $version when parsing succeeds and proceed to build $namespace
afterwards.

In @tests/Unit/Public/Get-SqlDscRSConfigFile.Tests.ps1:
- Around line 243-250: Rename the test case description to remove the word
"when" in the It block that reads 'Should return the configuration file when
piping SetupConfiguration'; update it to a description without "when" (e.g.,
'Should return the configuration file for piped SetupConfiguration' or 'Should
return the configuration file given piped SetupConfiguration') while leaving the
test body and calls to Get-SqlDscRSConfigFile, $mockSetupConfiguration, and the
assertions (Should -BeOfType, $result.Configuration.Dsn check, and Should
-Invoke Get-Content) unchanged.
🧹 Nitpick comments (3)
tests/Unit/Public/Get-SqlDscRSWebPortalApplicationName.Tests.ps1 (1)

66-126: Consider collapsing the repeated “version → expected name” cases into a single data-driven test.
Current coverage is good, but it’s a lot of copy/paste across versions.

Possible refactor (data-driven)
 Context 'When SQL Server version is 2016 (version 13) or later' {
     BeforeAll {
         Mock -CommandName Get-SqlDscRSVersion
     }
 
-    It 'Should return ReportServerWebApp for SQL Server 2016 (version 13)' {
-        Mock -CommandName Get-SqlDscRSVersion -MockWith {
-            return [System.Version] '13.0.4001.0'
-        }
-
-        $mockSetupConfiguration = @{
-            InstanceName = 'SSRS'
-        }
-
-        $result = $mockSetupConfiguration | Get-SqlDscRSWebPortalApplicationName
-
-        $result | Should -Be 'ReportServerWebApp'
-    }
+    It 'Should return <ExpectedApplicationName> for SQL Server version <Version>' -ForEach @(
+        @{ Version = '13.0.4001.0'; ExpectedApplicationName = 'ReportServerWebApp' }
+        @{ Version = '14.0.600.0' ; ExpectedApplicationName = 'ReportServerWebApp' }
+        @{ Version = '15.0.1100.0'; ExpectedApplicationName = 'ReportServerWebApp' }
+        @{ Version = '16.0.1000.0'; ExpectedApplicationName = 'ReportServerWebApp' }
+    ) {
+        Mock -CommandName Get-SqlDscRSVersion -MockWith {
+            return [System.Version] $Version
+        }
+
+        $mockSetupConfiguration = @{
+            InstanceName = 'SSRS'
+        }
+
+        $result = $mockSetupConfiguration | Get-SqlDscRSWebPortalApplicationName
+
+        $result | Should -Be $ExpectedApplicationName
+    }
 }

Also applies to: 128-160

CHANGELOG.md (2)

10-24: Inconsistent list nesting + too verbose for “Unreleased/Added”

Line 10 introduces a - SqlServerDsc grouping, but Lines 13-24 are not nested under it, which reads as a formatting mistake. Also, this is very detailed for a changelog entry (guideline: keep to ≤2 items per change type).

Proposed restructure + condense
 - SqlServerDsc
-  - Added class `ReportServerUri` to represent URLs returned by the
-    `GetReportServerUrls` CIM method on `MSReportServer_Instance`.
-- Added public command `Get-SqlDscRSUrl` to get the Report Server URLs for
-  SQL Server Reporting Services or Power BI Report Server. This command
-  invokes the `GetReportServerUrls` CIM method on `MSReportServer_Instance`
-  and returns an array of `ReportServerUri` objects containing the instance
-  name, application name, and URL for each configured URL.
-- Added public command `Get-SqlDscRSConfigFile` to get the RsReportServer.config
-  configuration file for SQL Server Reporting Services (SSRS) or Power BI
-  Report Server (PBIRS) as an XML document object. Supports three parameter
-  sets: `ByInstanceName` (looks up path via registry), `ByConfiguration`
-  (accepts pipeline input from `Get-SqlDscRSSetupConfiguration`), and `ByPath`
-  (reads from a direct file path). The returned XML object supports standard
-  XML navigation and XPath queries for accessing configuration settings.
+  - Added Reporting Services helper commands and types:
+    `Get-SqlDscRSUrl` and `Get-SqlDscRSConfigFile` (and related types).

212-221: Group/condense the new encryption-key commands in the changelog

These are three closely related commands; consider collapsing to a single bullet to keep the “Added” section concise (≤2 items per change type guideline).

Proposed condense
-- Added public command `New-SqlDscRSEncryptionKey` to delete and regenerate the
-  Reporting Services encryption key. Wraps the `DeleteEncryptionKey` CIM method.
-  Warning: This operation cannot be undone and renders all encrypted content
-  unreadable.
-- Added public command `Remove-SqlDscRSEncryptionKey` to remove all encrypted
-  content from the report server database. Wraps the `DeleteEncryptionKey` CIM
-  method with `DeleteEncryptedContent` mode.
-- Added public command `Remove-SqlDscRSEncryptedInformation` to remove all encrypted
-  information from the report server database, including stored credentials and
-  connection strings. Wraps the `DeleteEncryptedInformation` CIM method.
+- Added Reporting Services encryption key management commands:
+  `New-SqlDscRSEncryptionKey`, `Remove-SqlDscRSEncryptionKey`,
+  and `Remove-SqlDscRSEncryptedInformation`.

Copy link

@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

🤖 Fix all issues with AI agents
In @source/Public/Get-SqlDscRSUrl.ps1:
- Line 59: The OutputType attribute on the Get-SqlDscRSUrl cmdlet is declared as
[System.Object[]] but the comment-based .OUTPUTS documents ReportServerUri[], so
update the attribute to match the documented output type: change the OutputType
on the Get-SqlDscRSUrl function to reference the ReportServerUri type used in
the module (e.g., ReportServerUri[] or its fully-qualified type name) so the
attribute and .OUTPUTS are consistent.
🧹 Nitpick comments (1)
source/Public/Get-SqlDscRSUrl.ps1 (1)

142-162: Consider more efficient array building pattern.

The current implementation uses the += operator to build the array (line 160), which creates a new array on each iteration. For small collections this is acceptable, but a more efficient pattern would use a generic list or collect results in a pipeline.

♻️ Alternative implementation

Option 1: Use a generic list

-        # Build the result array
-        $reportServerUrls = @()
+        # Build the result array
+        $reportServerUrls = [System.Collections.Generic.List[ReportServerUri]]::new()

         for ($i = 0; $i -lt $result.ApplicationName.Count; $i++)
         {
             $applicationName = $result.ApplicationName[$i]
             $urls = $result.URLs[$i]

             # Each application can have multiple URLs
             foreach ($url in $urls)
             {
                 Write-Verbose -Message ($script:localizedData.Get_SqlDscRSUrl_FoundUrl -f $applicationName, $url)

                 $reportServerUrl = [ReportServerUri]::new()
                 $reportServerUrl.InstanceName = $instanceName
                 $reportServerUrl.ApplicationName = $applicationName
                 $reportServerUrl.Uri = $url

-                $reportServerUrls += $reportServerUrl
+                $reportServerUrls.Add($reportServerUrl)
             }
         }

-        return $reportServerUrls
+        return $reportServerUrls.ToArray()

Option 2: Use foreach to collect in pipeline

-        # Build the result array
-        $reportServerUrls = @()
-
-        for ($i = 0; $i -lt $result.ApplicationName.Count; $i++)
+        # Build the result array
+        $reportServerUrls = for ($i = 0; $i -lt $result.ApplicationName.Count; $i++)
         {
             $applicationName = $result.ApplicationName[$i]
             $urls = $result.URLs[$i]

             # Each application can have multiple URLs
             foreach ($url in $urls)
             {
                 Write-Verbose -Message ($script:localizedData.Get_SqlDscRSUrl_FoundUrl -f $applicationName, $url)

                 $reportServerUrl = [ReportServerUri]::new()
                 $reportServerUrl.InstanceName = $instanceName
                 $reportServerUrl.ApplicationName = $applicationName
                 $reportServerUrl.Uri = $url

-                $reportServerUrls += $reportServerUrl
+                $reportServerUrl
             }
         }

         return $reportServerUrls
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5594da0 and 4fac04d.

📒 Files selected for processing (4)
  • source/Public/Get-SqlDscRSConfigFile.ps1
  • source/Public/Get-SqlDscRSUrl.ps1
  • tests/Integration/Commands/Get-SqlDscRSUrl.Integration.Tests.ps1
  • tests/Unit/Public/Get-SqlDscRSWebPortalApplicationName.Tests.ps1
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/Integration/Commands/Get-SqlDscRSUrl.Integration.Tests.ps1
🧰 Additional context used
📓 Path-based instructions (11)
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-SqlDscRSConfigFile.ps1
  • source/Public/Get-SqlDscRSUrl.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-SqlDscRSConfigFile.ps1
  • source/Public/Get-SqlDscRSUrl.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-SqlDscRSConfigFile.ps1
  • source/Public/Get-SqlDscRSUrl.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-SqlDscRSConfigFile.ps1
  • source/Public/Get-SqlDscRSUrl.ps1
  • tests/Unit/Public/Get-SqlDscRSWebPortalApplicationName.Tests.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-SqlDscRSConfigFile.ps1
  • source/Public/Get-SqlDscRSUrl.ps1
  • tests/Unit/Public/Get-SqlDscRSWebPortalApplicationName.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:

  • source/Public/Get-SqlDscRSConfigFile.ps1
  • source/Public/Get-SqlDscRSUrl.ps1
  • tests/Unit/Public/Get-SqlDscRSWebPortalApplicationName.Tests.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-SqlDscRSConfigFile.ps1
  • source/Public/Get-SqlDscRSUrl.ps1
  • tests/Unit/Public/Get-SqlDscRSWebPortalApplicationName.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/Unit/Public/Get-SqlDscRSWebPortalApplicationName.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/Unit/Public/Get-SqlDscRSWebPortalApplicationName.Tests.ps1
tests/Unit/Public/*.[Tt]ests.ps1

📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines-pester.instructions.md)

Public commands: tests/Unit/Public/{Name}.Tests.ps1

Files:

  • tests/Unit/Public/Get-SqlDscRSWebPortalApplicationName.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/Public/Get-SqlDscRSWebPortalApplicationName.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/Public/Get-SqlDscRSWebPortalApplicationName.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/Public/Get-SqlDscRSWebPortalApplicationName.Tests.ps1
**/tests/Unit/**/*.ps1

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

**/tests/Unit/**/*.ps1: Unit tests must use SMO stub types from SMO.cs, never mock SMO types
Unit tests must add $env:SqlServerDscCI = $true in BeforeAll block and remove in AfterAll block
Load SMO stub types from SMO.cs in unit test files using Add-Type -Path "$PSScriptRoot/../Stubs/SMO.cs"

Files:

  • tests/Unit/Public/Get-SqlDscRSWebPortalApplicationName.Tests.ps1
🧠 Learnings (60)
📓 Common learnings
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2026-01-01T11:57:15.298Z
Learning: Applies to **/tests/Integration/**/*.ps1 : Integration tests must use `Connect-SqlDscDatabaseEngine` for SQL Server DB session with correct CI credentials
📚 Learning: 2026-01-01T11:57:15.298Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2026-01-01T11:57:15.298Z
Learning: Applies to **/Public/**/*.ps1 : Public commands must follow the naming format `{Verb}-SqlDsc{Noun}`

Applied to files:

  • source/Public/Get-SqlDscRSConfigFile.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 : Export functions using the `*-TargetResource` pattern

Applied to files:

  • source/Public/Get-SqlDscRSConfigFile.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-SqlDscRSConfigFile.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 include comment-based help with .DESCRIPTION section containing Requirements and Known issues sections with a link to all open issues on GitHub

Applied to files:

  • source/Public/Get-SqlDscRSConfigFile.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 : Unused mandatory parameters in `Set-TargetResource` and `Test-TargetResource` should include "Not used in <function_name>" in the help comment

Applied to files:

  • source/Public/Get-SqlDscRSConfigFile.ps1
  • tests/Unit/Public/Get-SqlDscRSWebPortalApplicationName.Tests.ps1
📚 Learning: 2025-11-22T17:36:09.703Z
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 2343
File: source/Classes/004.DatabaseFileGroupSpec.ps1:5-34
Timestamp: 2025-11-22T17:36:09.703Z
Learning: The comment-based help requirements for ## Requirements and ## Known issues sections only apply to class-based DSC resources (classes decorated with [DscResource(...)]) in source/Classes/**/*.ps1, not to regular helper classes, DTO classes, or specification classes in the same directory.

Applied to files:

  • source/Public/Get-SqlDscRSConfigFile.ps1
📚 Learning: 2025-08-22T12:39:02.400Z
Learnt from: ChristophHannappel
Repo: dsccommunity/SharePointDsc PR: 1457
File: .vscode/launch.json:43-44
Timestamp: 2025-08-22T12:39:02.400Z
Learning: The SharePointDsc repository uses "tests" (lowercase) for the test directory, not "Tests" (uppercase). Launch configurations and other path references should use the correct lowercase "tests" folder name.

Applied to files:

  • source/Public/Get-SqlDscRSConfigFile.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} : Avoid `ConvertTo-SecureString -AsPlainText` in production code

Applied to files:

  • source/Public/Get-SqlDscRSConfigFile.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} : Avoid empty catch blocks (instead use `-ErrorAction SilentlyContinue`)

Applied to files:

  • source/Public/Get-SqlDscRSConfigFile.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 state-changing functions, use `SupportsShouldProcess` attribute with `ConfirmImpact` set to 'Low', 'Medium', or 'High' depending on risk

Applied to files:

  • source/Public/Get-SqlDscRSConfigFile.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} : Avoid hardcoded computer names, use cross-platform `Get-ComputerName` instead of `$env:COMPUTERNAME`

Applied to files:

  • source/Public/Get-SqlDscRSConfigFile.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} : Avoid global variables (exception: `$global:DSCMachineStatus`)

Applied to files:

  • source/Public/Get-SqlDscRSConfigFile.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 `Write-Warning` for: Non-fatal issues requiring attention; Deprecated functionality usage; Configuration problems that don't block execution

Applied to files:

  • source/Public/Get-SqlDscRSConfigFile.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} : Set `$ErrorActionPreference = 'Stop'` before commands using `-ErrorAction 'Stop'` and restore previous value directly after invocation (do not use try-catch-finally)

Applied to files:

  • source/Public/Get-SqlDscRSConfigFile.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-SqlDscRSConfigFile.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} : Don't use `Invoke-Expression` (use `&` operator instead)

Applied to files:

  • source/Public/Get-SqlDscRSConfigFile.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-SqlDscRSConfigFile.ps1
📚 Learning: 2025-09-28T18:25:38.659Z
Learnt from: kilasuit
Repo: dsccommunity/AzureDevOpsDsc PR: 43
File: .github/ISSUE_TEMPLATE/presentationRequest.yml:13-29
Timestamp: 2025-09-28T18:25:38.659Z
Learning: In the AzureDevOpsDsc repository, the user kilasuit intentionally includes PGP guidance and password scheme suggestions in the presentation request template placeholder text, despite security concerns.

Applied to files:

  • source/Public/Get-SqlDscRSConfigFile.ps1
📚 Learning: 2025-08-16T13:35:08.323Z
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 2134
File: source/Public/Get-SqlDscLogin.ps1:0-0
Timestamp: 2025-08-16T13:35:08.323Z
Learning: In PowerShell, users expect to receive $null when no objects are found or when a non-terminating error occurs, rather than empty arrays. This is normal PowerShell behavior and should be maintained in DSC commands.

Applied to files:

  • source/Public/Get-SqlDscRSUrl.ps1
  • tests/Unit/Public/Get-SqlDscRSWebPortalApplicationName.Tests.ps1
📚 Learning: 2025-08-16T13:15:17.108Z
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 2134
File: source/Public/Get-SqlDscLogin.ps1:27-38
Timestamp: 2025-08-16T13:15:17.108Z
Learning: For PowerShell comment-based help in .OUTPUTS sections: Each distinct type that can be returned should have its own .OUTPUTS entry, even if the implementation technically always returns an array. This follows official PowerShell documentation standards and helps users understand what to expect in different usage scenarios.

Applied to files:

  • source/Public/Get-SqlDscRSUrl.ps1
📚 Learning: 2025-08-16T13:15:17.108Z
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 2134
File: source/Public/Get-SqlDscLogin.ps1:27-38
Timestamp: 2025-08-16T13:15:17.108Z
Learning: For PowerShell comment-based help .OUTPUTS sections: Each distinct return type should have its own .OUTPUTS entry with a description of when that type is returned, even if the underlying implementation uses array casting. This follows official PowerShell documentation standards where you list each return type on its own line under .OUTPUTS with clear descriptions of the conditions for each type.

Applied to files:

  • source/Public/Get-SqlDscRSUrl.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 `[Nullable[{FullTypeName}]]` syntax for value-type properties (e.g., `[Nullable[System.Int32]]`)

Applied to files:

  • source/Public/Get-SqlDscRSUrl.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} : Do not use the unary comma operator (`,`) in return statements to force an array

Applied to files:

  • source/Public/Get-SqlDscRSUrl.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 `[OutputType({return type})]` for functions with output, use `[OutputType()]` for functions with no output

Applied to files:

  • source/Public/Get-SqlDscRSUrl.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 : `Get-TargetResource` function must return a hashtable with all resource properties

Applied to files:

  • source/Public/Get-SqlDscRSUrl.ps1
📚 Learning: 2025-08-16T13:22:15.230Z
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 2134
File: tests/Unit/Public/Get-SqlDscLogin.Tests.ps1:78-93
Timestamp: 2025-08-16T13:22:15.230Z
Learning: In PowerShell unit tests for parameter validation in SqlServerDsc, accessing parameter attributes directly like `$cmd.Parameters['ParameterName'].Attributes.Mandatory` works correctly because PowerShell automatically iterates through the array and returns the property values. Additional filtering to ParameterAttribute is not necessary when the parameter structure is known and controlled.

Applied to files:

  • source/Public/Get-SqlDscRSUrl.ps1
  • tests/Unit/Public/Get-SqlDscRSWebPortalApplicationName.Tests.ps1
📚 Learning: 2025-08-09T19:29:36.323Z
Learnt from: johlju
Repo: dsccommunity/DscResource.Test PR: 167
File: source/Private/Test-FileContainsClassResource.ps1:44-56
Timestamp: 2025-08-09T19:29:36.323Z
Learning: In the DscResource.Test repository, DSC resource attributes are consistently written as `[DscResource(...)]` rather than using variations like `[DscResourceAttribute()]` or fully qualified names like `[Microsoft.PowerShell.DesiredStateConfiguration.DscResource()]`. The Test-FileContainsClassResource function should focus on detecting the standard `[DscResource(...)]` pattern that is actually used in the codebase.

Applied to files:

  • source/Public/Get-SqlDscRSUrl.ps1
📚 Learning: 2025-08-17T10:48:15.384Z
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 2136
File: source/suffix.ps1:24-24
Timestamp: 2025-08-17T10:48:15.384Z
Learning: In source/suffix.ps1, the Write-Verbose message in the catch block for Import-SqlDscPreferredModule does not need localization because the exception message from Import-SqlDscPreferredModule is already localized by that command, making it an edge case exception to the localization guidelines.

Applied to files:

  • source/Public/Get-SqlDscRSUrl.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-SqlDscRSUrl.ps1
📚 Learning: 2025-11-27T17:58:42.327Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-localization.instructions.md:0-0
Timestamp: 2025-11-27T17:58:42.327Z
Learning: Applies to source/**/*.ps1 : Use localized string keys from $script:localizedData, not hardcoded strings, in diagnostic messages

Applied to files:

  • source/Public/Get-SqlDscRSUrl.ps1
📚 Learning: 2025-08-30T18:18:31.528Z
Learnt from: dan-hughes
Repo: dsccommunity/ActiveDirectoryCSDsc PR: 158
File: source/Classes/020.AdcsOnlineResponder.ps1:0-0
Timestamp: 2025-08-30T18:18:31.528Z
Learning: For ADCS resources in ActiveDirectoryCSDsc, when catching exceptions from Install-Adcs* commands to determine installation state, use string matching on the exception message (e.g., `$_.Exception.ToString() -match 'OnlineResponderSetupException$'`) instead of catching specific exception types. This avoids dependency on importing types that may not be available in all environments like CI systems or DSC authoring machines.

Applied to files:

  • source/Public/Get-SqlDscRSUrl.ps1
📚 Learning: 2025-10-04T21:33:23.022Z
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.

Applied to files:

  • source/Public/Get-SqlDscRSUrl.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 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

Applied to files:

  • tests/Unit/Public/Get-SqlDscRSWebPortalApplicationName.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 : All public commands require parameter set validation tests in unit tests

Applied to files:

  • tests/Unit/Public/Get-SqlDscRSWebPortalApplicationName.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/Unit/Public/Get-SqlDscRSWebPortalApplicationName.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 parameter properties test template with `Get-Command` to validate individual parameter attributes (e.g., Mandatory flag) in Pester unit tests

Applied to files:

  • tests/Unit/Public/Get-SqlDscRSWebPortalApplicationName.Tests.ps1
📚 Learning: 2026-01-01T11:57:15.298Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2026-01-01T11:57:15.298Z
Learning: Applies to **/tests/Integration/**/*.ps1 : Integration tests must use `Connect-SqlDscDatabaseEngine` for SQL Server DB session with correct CI credentials

Applied to files:

  • tests/Unit/Public/Get-SqlDscRSWebPortalApplicationName.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/Public/*.[Tt]ests.ps1 : Public commands: `tests/Unit/Public/{Name}.Tests.ps1`

Applied to files:

  • tests/Unit/Public/Get-SqlDscRSWebPortalApplicationName.Tests.ps1
📚 Learning: 2026-01-01T11:57:15.298Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2026-01-01T11:57:15.298Z
Learning: Applies to **/tests/Unit/**/*.ps1 : Unit tests must add `$env:SqlServerDscCI = $true` in `BeforeAll` block and remove in `AfterAll` block

Applied to files:

  • tests/Unit/Public/Get-SqlDscRSWebPortalApplicationName.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 : Set `$PSDefaultParameterValues` for `Mock:ModuleName`, `Should:ModuleName`, `InModuleScope:ModuleName`

Applied to files:

  • tests/Unit/Public/Get-SqlDscRSWebPortalApplicationName.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/Public/Get-SqlDscRSWebPortalApplicationName.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/Public/Get-SqlDscRSWebPortalApplicationName.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 add `param()` inside Pester blocks when using `-ForEach`

Applied to files:

  • tests/Unit/Public/Get-SqlDscRSWebPortalApplicationName.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 : Pass all mandatory parameters to avoid prompts

Applied to files:

  • tests/Unit/Public/Get-SqlDscRSWebPortalApplicationName.Tests.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} : Parameters should use full type name

Applied to files:

  • tests/Unit/Public/Get-SqlDscRSWebPortalApplicationName.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: Follow PowerShell style and test guideline instructions strictly

Applied to files:

  • tests/Unit/Public/Get-SqlDscRSWebPortalApplicationName.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 `$PSDefaultParameterValues` only for Pester commands (`Describe`, `Context`, `It`, `Mock`, `Should`, `InModuleScope`)

Applied to files:

  • tests/Unit/Public/Get-SqlDscRSWebPortalApplicationName.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 : Omit `-MockWith` when returning `$null`

Applied to files:

  • tests/Unit/Public/Get-SqlDscRSWebPortalApplicationName.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 : Mock variables prefix: 'mock'

Applied to files:

  • tests/Unit/Public/Get-SqlDscRSWebPortalApplicationName.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/Unit/Public/Get-SqlDscRSWebPortalApplicationName.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/Public/Get-SqlDscRSWebPortalApplicationName.Tests.ps1
📚 Learning: 2025-08-28T15:44:12.628Z
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 2150
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:35-35
Timestamp: 2025-08-28T15:44:12.628Z
Learning: The SqlServerDsc repository uses RequiredModules.psd1 to specify Pester with Version = 'latest' and AllowPrerelease = $true, ensuring the latest Pester version (well beyond 5.4) is available, which supports Should -Invoke syntax and other modern Pester features.

Applied to files:

  • tests/Unit/Public/Get-SqlDscRSWebPortalApplicationName.Tests.ps1
📚 Learning: 2025-08-28T15:44:12.628Z
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 2150
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:35-35
Timestamp: 2025-08-28T15:44:12.628Z
Learning: The repository uses RequiredModules.psd1 to specify Pester version requirements with RequiredVersion = 'latest', which ensures compatibility with Should -Invoke syntax (requires Pester 5.4+).

Applied to files:

  • tests/Unit/Public/Get-SqlDscRSWebPortalApplicationName.Tests.ps1
📚 Learning: 2026-01-01T11:57:15.298Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2026-01-01T11:57:15.298Z
Learning: Applies to **/tests/Unit/**/*.ps1 : Unit tests must use SMO stub types from SMO.cs, never mock SMO types

Applied to files:

  • tests/Unit/Public/Get-SqlDscRSWebPortalApplicationName.Tests.ps1
📚 Learning: 2025-08-17T10:13:30.079Z
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 2136
File: source/Public/Remove-SqlDscLogin.ps1:104-108
Timestamp: 2025-08-17T10:13:30.079Z
Learning: In SqlServerDsc unit tests, SMO object stubs (like Login objects) should have properly mocked Parent properties with correct Server stub types and valid InstanceName values, rather than handling null Parent scenarios in production code.

Applied to files:

  • tests/Unit/Public/Get-SqlDscRSWebPortalApplicationName.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 add an empty `-MockWith` block

Applied to files:

  • tests/Unit/Public/Get-SqlDscRSWebPortalApplicationName.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 : Inside `It` blocks, assign unused return objects to `$null` (unless part of pipeline)

Applied to files:

  • tests/Unit/Public/Get-SqlDscRSWebPortalApplicationName.Tests.ps1
📚 Learning: 2026-01-01T11:57:15.298Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2026-01-01T11:57:15.298Z
Learning: Applies to **/tests/Integration/**/*.ps1 : Integration tests must use `Disconnect-SqlDscDatabaseEngine` after `Connect-SqlDscDatabaseEngine`

Applied to files:

  • tests/Unit/Public/Get-SqlDscRSWebPortalApplicationName.Tests.ps1
📚 Learning: 2025-09-25T16:38:08.867Z
Learnt from: johlju
Repo: dsccommunity/ActiveDirectoryDsc PR: 741
File: tests/Integration/MSFT_ADReadOnlyDomainControllerAccount.Integration.Tests.ps1:102-104
Timestamp: 2025-09-25T16:38:08.867Z
Learning: Test-DscConfiguration cmdlet returns string values 'True' or 'False', not boolean values. Therefore, Should -Be 'True' is correct, and Should -BeTrue would be incorrect for this cmdlet.

Applied to files:

  • tests/Unit/Public/Get-SqlDscRSWebPortalApplicationName.Tests.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 (2)
tests/Unit/Public/Get-SqlDscRSWebPortalApplicationName.Tests.ps1 (1)

1-170: LGTM! Test structure and parameter rename are correct.

The test file correctly implements the parameter rename from Configuration to SetupConfiguration throughout all test cases. The test structure follows Pester v5 guidelines with proper setup/teardown blocks, data-driven tests using -ForEach, and appropriate mocking in BeforeAll blocks.

source/Public/Get-SqlDscRSConfigFile.ps1 (1)

1-209: LGTM! Well-structured function with comprehensive error handling.

The function follows all DSC Community guidelines with:

  • Proper comment-based help with all required sections
  • Correct parameter structure with three parameter sets
  • Comprehensive error handling with localized messages
  • Good use of Get-Content -Raw -Force for performance and error handling (as noted in commit message)
  • Proper use of $PSCmdlet.ThrowTerminatingError() with structured error records

Copy link
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 reviewed 19 files and all commit messages, made 1 comment, and resolved 1 discussion.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @johlju).

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

@johlju reviewed 2 files and all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @johlju).

@johlju johlju merged commit 4eae9db into dsccommunity:main Jan 10, 2026
3 of 7 checks passed
@johlju johlju deleted the f/improve-rs-service-account branch January 10, 2026 14:45
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.

1 participant