Skip to content

Conversation

@johlju
Copy link
Member

@johlju johlju commented Jan 14, 2026

Pull Request (PR) description

  • Added public commands Set-SqlDscRSUnattendedExecutionAccount and
    Remove-SqlDscRSUnattendedExecutionAccount to manage the unattended execution
    account for Reporting Services. These wrap the SetUnattendedExecutionAccount
    CIM method.

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 14, 2026

Walkthrough

Adds two new PowerShell functions for managing SSRS/Power BI Report Server unattended execution accounts, enhances Get-SqlDscRSConfiguration with retry logic parameters, refactors error handling in SSL certificate operations, corrects output types for certificate binding functions, updates integration tests and documentation to reflect HTTPS setup, and adds localization strings.

Changes

Cohort / File(s) Summary
New Unattended Execution Account Functions
source/Public/Set-SqlDscRSUnattendedExecutionAccount.ps1, source/Public/Remove-SqlDscRSUnattendedExecutionAccount.ps1
Two new public functions added to manage unattended execution accounts. Both support ShouldProcess (Medium impact), PassThru, and Force parameters. Set converts credential SecureString to plaintext, clears memory in finally block, and calls SetUnattendedExecutionAccount CIM method. Remove invokes RemoveUnattendedExecutionAccount CIM method. Both include error handling with specific error IDs (RSRSUEA0001, RSSRSUEA0001).
Get-SqlDscRSConfiguration Retry Enhancement
source/Public/Get-SqlDscRSConfiguration.ps1
Added three new parameters to control retry behavior when CIM instance is not found: RetryCount (default 1), RetryDelaySeconds (default 30), and SkipRetry switch. Implements retry loop with configurable delays and filtered instance name matching. Includes debug/verbose messaging and updated examples.
SSL Certificate Error Handling Refactoring
source/Public/Add-SqlDscRSSslCertificateBinding.ps1, source/Public/Get-SqlDscRSSslCertificate.ps1, source/Public/Get-SqlDscRSSslCertificateBinding.ps1, source/Public/Remove-SqlDscRSSslCertificateBinding.ps1
Refactored catch blocks across four functions to use multi-step error construction: build message, create InvalidOperationException with original error, construct ErrorRecord, then throw. Preserves error IDs and InvalidOperation categories while decoupling message formatting from ErrorRecord construction.
Output Type Corrections
source/Public/Set-SqlDscRSSslCertificateBinding.ps1, source/Public/Remove-SqlDscRSSslCertificateBinding.ps1
Updated OutputType attribute from [System.Object] to [Microsoft.Management.Infrastructure.CimInstance] for both functions to accurately reflect returned CIM instance objects.
Localization Strings
source/en-US/SqlServerDsc.strings.psd1
Added 11 new public string resources: one for Get-SqlDscRSConfiguration retry messaging (Get_SqlDscRSConfiguration_RetryingAfterDelay) and ten for Set/Remove unattended execution account operations (Setting, ShouldProcessDescription, ShouldProcessConfirmation, ShouldProcessCaption, FailedToSet/FailedToRemove).
Pipeline & Configuration
.vscode/settings.json, CHANGELOG.md, azure-pipelines.yml
Added "contoso" to VSCode cSpell dictionary. Updated CHANGELOG with new commands and Get-SqlDscRSConfiguration retry behavior. Extended Azure Pipelines with Group 7 test entries for UnattendedExecutionAccount integration tests across SQL Server, BI Report Server, and Power BI variants.
Documentation
source/WikiSource/Deploy-Power-BI-Report-Server.md
Comprehensive HTTPS/SSL setup documentation: introduces self-signed certificate creation via PSPKI, certificate binding to ReportServerWebService/WebApp, HTTPS URL configuration on port 443, production guidance, and new HTTP-only development appendix. Reorganizes phases to accommodate SSL certificate setup workflow.
Integration Tests
tests/Integration/Commands/Remove-SqlDscRSUnattendedExecutionAccount.Integration.Tests.ps1, tests/Integration/Commands/Set-SqlDscRSUnattendedExecutionAccount.Integration.Tests.ps1, tests/Integration/Commands/Add-SqlDscRSSslCertificateBinding.Integration.Tests.ps1, tests/Integration/Commands/Get-SqlDscRSSslCertificate.Integration.Tests.ps1, tests/Integration/Commands/Get-SqlDscRSSslCertificateBinding.Integration.Tests.ps1, tests/Integration/Commands/Remove-SqlDscRSSslCertificateBinding.Integration.Tests.ps1, tests/Integration/Commands/Set-SqlDscRSSslCertificateBinding.Integration.Tests.ps1
New test suites for unattended execution account functions with contexts for SSRS 2017/2019/2022 and Power BI. Existing SSL certificate tests updated with version-specific context descriptions and assertion style changes (removed Should -Not -Throw wrappers, direct command invocation). Updated context descriptions to specify SQL Server versions (2017, 2019, 2022) instead of generic labels.
Unit Tests
tests/Unit/Public/Get-SqlDscRSConfiguration.Tests.ps1, tests/Unit/Public/Get-SqlDscRSSslCertificateBinding.Tests.ps1, tests/Unit/Public/Remove-SqlDscRSSslCertificateBinding.Tests.ps1, tests/Unit/Public/Remove-SqlDscRSUnattendedExecutionAccount.Tests.ps1, tests/Unit/Public/Set-SqlDscRSSslCertificateBinding.Tests.ps1, tests/Unit/Public/Set-SqlDscRSUnattendedExecutionAccount.Tests.ps1
Added comprehensive unit test suites for new unattended execution account functions (170-201 lines each) covering parameter sets, successful/failed execution, PassThru/Force/WhatIf scenarios, and error handling. Enhanced Get-SqlDscRSConfiguration tests with parameter validation, default values, and retry behavior scenarios (142 additions). Updated existing SSL certificate tests with new assertion patterns and Lcid parameter validation.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title directly and clearly identifies the main change: addition of two new commands for managing SQL Server Reporting Services unattended execution accounts.
Description check ✅ Passed The description is directly related to the changeset, clearly explaining the purpose of the two new public commands and their functionality.
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.


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 Jan 14, 2026
@codecov
Copy link

codecov bot commented Jan 14, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94%. Comparing base (7af9141) to head (d833508).

Additional details and impacted files

Impacted file tree graph

@@          Coverage Diff          @@
##            main   #2410   +/-   ##
=====================================
  Coverage     94%     94%           
=====================================
  Files        215     217    +2     
  Lines      10864   10926   +62     
=====================================
+ Hits       10243   10305   +62     
  Misses       621     621           
Flag Coverage Δ
unit 94% <100%> (+<1%) ⬆️
Files with missing lines Coverage Δ
...ource/Public/Add-SqlDscRSSslCertificateBinding.ps1 100% <100%> (ø)
source/Public/Get-SqlDscRSConfiguration.ps1 100% <100%> (ø)
source/Public/Get-SqlDscRSSslCertificate.ps1 100% <100%> (ø)
...ource/Public/Get-SqlDscRSSslCertificateBinding.ps1 100% <100%> (ø)
...ce/Public/Remove-SqlDscRSSslCertificateBinding.ps1 100% <100%> (ø)
...blic/Remove-SqlDscRSUnattendedExecutionAccount.ps1 100% <100%> (ø)
...ource/Public/Set-SqlDscRSSslCertificateBinding.ps1 100% <100%> (ø)
.../Public/Set-SqlDscRSUnattendedExecutionAccount.ps1 100% <100%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@johlju johlju marked this pull request as ready for review January 15, 2026 16:54
@johlju johlju requested a review from a team as a code owner January 15, 2026 16:54
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: 4

🤖 Fix all issues with AI agents
In `@source/Public/Remove-SqlDscRSUnattendedExecutionAccount.ps1`:
- Around line 115-125: Replace the catch block to use the helper functions:
build the message with
($script:localizedData.Remove_SqlDscRSUnattendedExecutionAccount_FailedToRemove
-f $instanceName, $_.Exception.Message), create an exception via
New-InvalidOperationException -Message <that message>, create an ErrorRecord via
New-ErrorRecord -Exception <that exception> -ErrorId 'RSRSUEA0001' -Category
InvalidOperation -TargetObject $Configuration, and pass that ErrorRecord to
$PSCmdlet.ThrowTerminatingError; this replaces the direct ErrorRecord
constructor and fixes the ErrorId to match the localized suffix (RSRSUEA0001).

In `@source/Public/Set-SqlDscRSUnattendedExecutionAccount.ps1`:
- Around line 139-149: Replace the manual ErrorRecord construction in the catch
of Set-SqlDscRSUnattendedExecutionAccount: create an InvalidOperationException
using New-InvalidOperationException with the formatted localized message (use
$instanceName and $_.Exception.Message), then create an ErrorRecord via
New-ErrorRecord (pass the exception and correct ErrorId 'SSRSUEA0001'), and pass
that record to $PSCmdlet.ThrowTerminatingError; this uses the helper functions
and fixes the ErrorId mismatch.

In `@source/WikiSource/Deploy-Power-BI-Report-Server.md`:
- Line 834: Replace the incorrect command name occurrences of
Get-SqlDscRSSqlCertificateBinding with the correct
Get-SqlDscRSSslCertificateBinding; search for any references to
Get-SqlDscRSSqlCertificateBinding in the doc and update them to
Get-SqlDscRSSslCertificateBinding (e.g., the pipeline expression using $rsConfig
| Get-SqlDscRSSslCertificateBinding) so the command name reflects "SSL" not
"SQL".

In
`@tests/Integration/Commands/Remove-SqlDscRSUnattendedExecutionAccount.Integration.Tests.ps1`:
- Around line 41-45: The context "When removing unattended execution account for
SQL Server Reporting Services" tagged 'Integration_SQL2017_RS' is missing its
test; add an It block that uses the $script:configuration set in BeforeAll and
invokes Remove-SqlDscRSUnattendedExecutionAccount to perform the removal and
assert success. Specifically, create an It block (matching other contexts) that
calls Remove-SqlDscRSUnattendedExecutionAccount -Configuration
$script:configuration -InstanceName 'SSRS' -ErrorAction 'Stop' (or appropriate
parameters used in other tests) and include an assertion (e.g., that the cmdlet
returned true or no error was thrown) to validate the operation.
🧹 Nitpick comments (12)
source/Public/Set-SqlDscRSSslCertificateBinding.ps1 (2)

96-103: Consider typing Configuration as CimInstance now that output is CimInstance.

Currently [System.Object] $Configuration will accept anything and then fail later when .InstanceName is accessed; a stronger type improves parameter binding errors and keeps help/usage consistent.

Proposed diff
         [Parameter(Mandatory = $true, ValueFromPipeline = $true)]
-        [System.Object]
+        [Microsoft.Management.Infrastructure.CimInstance]
         $Configuration,

162-185: Prefer culture-invariant / null-safe hash normalization (even though hex is usually safe).

ToLower() is culture-sensitive and will throw if CertificateHash is ever $null. A small guard + ToLowerInvariant() (or a case-insensitive compare) makes this more robust.

Proposed diff
-            $normalizedHash = $CertificateHash.ToLower()
+            $normalizedHash = $CertificateHash.ToLowerInvariant()

             # Remove bindings that don't match the desired configuration
             foreach ($binding in $applicationBindings)
             {
-                $shouldRemove = $binding.CertificateHash.ToLower() -ne $normalizedHash -or
+                $bindingHash = if ($null -ne $binding.CertificateHash) { $binding.CertificateHash.ToLowerInvariant() } else { '' }
+
+                $shouldRemove = $bindingHash -ne $normalizedHash -or
                     $binding.IPAddress -ne $IPAddress -or
                     $binding.Port -ne $Port
             }

             # Check if the desired binding already exists
             $bindingExists = $applicationBindings | Where-Object -FilterScript {
-                $_.CertificateHash.ToLower() -eq $normalizedHash -and
+                ($null -ne $_.CertificateHash) -and
+                $_.CertificateHash.ToLowerInvariant() -eq $normalizedHash -and
                 $_.IPAddress -eq $IPAddress -and
                 $_.Port -eq $Port
             }
source/Public/Set-SqlDscRSUnattendedExecutionAccount.ps1 (1)

83-83: OutputType should be CimInstance for consistency.

Other similar commands in this PR (e.g., Remove-SqlDscRSSslCertificateBinding) use [OutputType([Microsoft.Management.Infrastructure.CimInstance])]. This should be consistent since PassThru returns the configuration CIM instance.

Suggested fix
-    [OutputType([System.Object])]
+    [OutputType([Microsoft.Management.Infrastructure.CimInstance])]
source/Public/Remove-SqlDscRSUnattendedExecutionAccount.ps1 (1)

73-73: OutputType should be CimInstance for consistency.

Same as Set-SqlDscRSUnattendedExecutionAccount, this should use [OutputType([Microsoft.Management.Infrastructure.CimInstance])] since PassThru returns the configuration CIM instance.

Suggested fix
-    [OutputType([System.Object])]
+    [OutputType([Microsoft.Management.Infrastructure.CimInstance])]
tests/Unit/Public/Get-SqlDscRSConfiguration.Tests.ps1 (2)

65-75: Test description doesn't match assertions.

The It description states "Should have RetryCount default value of 1" but the test only verifies the parameter is non-mandatory and has type Int32. The actual default value of 1 is not validated.

Consider either:

  1. Update the description to "Should have RetryCount as a non-mandatory Int32 parameter"
  2. Or add an assertion to verify the actual default value
Option 1: Update description to match assertions
-        It 'Should have RetryCount default value of 1' {
+        It 'Should have RetryCount as a non-mandatory Int32 parameter' {
             $parameterInfo = (Get-Command -Name 'Get-SqlDscRSConfiguration').Parameters['RetryCount']

             $parameterInfo.Attributes.Where({ $_ -is [System.Management.Automation.ParameterAttribute] }).Mandatory | Should -BeFalse

-            $defaultValue = $parameterInfo.Attributes.Where({ $_ -is [System.Management.Automation.PSDefaultValueAttribute] }).Value
-
-            # Check via reflection since default values are set in the param block
-            $functionInfo = Get-Command -Name 'Get-SqlDscRSConfiguration'
-            $functionInfo.Parameters['RetryCount'].ParameterType | Should -Be ([System.Int32])
+            $parameterInfo.ParameterType | Should -Be ([System.Int32])
         }

77-82: Test description doesn't match assertions.

Similar to the previous test, the description "Should have RetryDelaySeconds default value of 30" is misleading since only non-mandatory status and type are verified, not the actual default value.

Update description to match assertions
-        It 'Should have RetryDelaySeconds default value of 30' {
+        It 'Should have RetryDelaySeconds as a non-mandatory Int32 parameter' {
             $parameterInfo = (Get-Command -Name 'Get-SqlDscRSConfiguration').Parameters['RetryDelaySeconds']

             $parameterInfo.Attributes.Where({ $_ -is [System.Management.Automation.ParameterAttribute] }).Mandatory | Should -BeFalse
             $parameterInfo.ParameterType | Should -Be ([System.Int32])
         }
tests/Unit/Public/Remove-SqlDscRSUnattendedExecutionAccount.Tests.ps1 (3)

75-81: Avoid using Should -Not -Throw – invoke commands directly.

Per coding guidelines, commands should be invoked directly without wrapping in Should -Not -Throw. The mock invocation assertion already validates successful execution.

♻️ Invoke command directly
         It 'Should remove unattended execution account without errors' {
-            { $mockCimInstance | Remove-SqlDscRSUnattendedExecutionAccount -Confirm:$false } | Should -Not -Throw
+            $mockCimInstance | Remove-SqlDscRSUnattendedExecutionAccount -Confirm:$false

             Should -Invoke -CommandName Invoke-RsCimMethod -ParameterFilter {
                 $MethodName -eq 'RemoveUnattendedExecutionAccount'
             } -Exactly -Times 1
         }

116-120: Avoid using Should -Not -Throw – invoke commands directly.

♻️ Invoke command directly
         It 'Should remove unattended execution account without confirmation' {
-            { $mockCimInstance | Remove-SqlDscRSUnattendedExecutionAccount -Force } | Should -Not -Throw
+            $mockCimInstance | Remove-SqlDscRSUnattendedExecutionAccount -Force

             Should -Invoke -CommandName Invoke-RsCimMethod -Exactly -Times 1
         }

164-168: Avoid using Should -Not -Throw – invoke commands directly.

♻️ Invoke command directly
         It 'Should remove unattended execution account' {
-            { Remove-SqlDscRSUnattendedExecutionAccount -Configuration $mockCimInstance -Confirm:$false } | Should -Not -Throw
+            Remove-SqlDscRSUnattendedExecutionAccount -Configuration $mockCimInstance -Confirm:$false

             Should -Invoke -CommandName Invoke-RsCimMethod -Exactly -Times 1
         }
tests/Integration/Commands/Remove-SqlDscRSUnattendedExecutionAccount.Integration.Tests.ps1 (1)

52-54: Avoid Should -Not -Throw - invoke commands directly.

Per coding guidelines, Should -Not -Throw should not be used in tests. Instead, invoke the command directly and let any exception fail the test naturally with -ErrorAction 'Stop'.

♻️ Proposed refactor
         It 'Should not throw when removing unattended execution account' {
-            { $script:configuration | Remove-SqlDscRSUnattendedExecutionAccount -Force -ErrorAction 'Stop' } | Should -Not -Throw
+            $script:configuration | Remove-SqlDscRSUnattendedExecutionAccount -Force -ErrorAction 'Stop'
         }

Apply the same change to the other It blocks at lines 62-64 and 72-74.

tests/Integration/Commands/Set-SqlDscRSUnattendedExecutionAccount.Integration.Tests.ps1 (2)

42-56: Context descriptions should be unique across SQL Server versions.

Lines 42, 58, and 71 have identical Context descriptions despite targeting different SQL Server versions (2017, 2019, 2022). While the tags differentiate them at runtime, unique descriptions improve readability and test output clarity.

Also, the note comment on line 52 explaining potential test failures should be consistent across all similar Context blocks.

♻️ Suggested improvement
-    Context 'When setting unattended execution account for SQL Server Reporting Services' -Tag @('Integration_SQL2017_RS') {
+    Context 'When setting unattended execution account for SQL Server Reporting Services 2017' -Tag @('Integration_SQL2017_RS') {

Apply similar version-specific naming to the other Context blocks (2019, 2022).


58-69: Add note comment for consistency.

This Context block (and the SQL2022 block at line 71) should include the same note comment present in the SQL2017 Context explaining that the test may fail if the account doesn't exist.

♻️ Suggested addition
         $script:testCredential = [System.Management.Automation.PSCredential]::new($script:testUsername, $script:testPassword)
     }

+    # Note: This test may fail if the account doesn't exist. This is expected behavior.
     It 'Should set unattended execution account' {

…and Set-SqlDscRSUnattendedExecutionAccount functions for improved clarity and consistency

Add integration test to verify no exceptions are thrown when removing unattended execution account
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 `@tests/Unit/Public/Remove-SqlDscRSUnattendedExecutionAccount.Tests.ps1`:
- Around line 134-136: The test expects a terminating error with ErrorId
'RSRUEA0001' but the implementation in Remove-SqlDscRSUnattendedExecutionAccount
(Remove-SqlDscRSUnattendedExecutionAccount.ps1) throws 'RSRSUEA0001' (extra
'S'); fix by updating the thrown/Write-Error/Throw call inside
Remove-SqlDscRSUnattendedExecutionAccount to use the correct ErrorId
'RSRUEA0001' so the test and implementation match.
♻️ Duplicate comments (1)
source/Public/Remove-SqlDscRSUnattendedExecutionAccount.ps1 (1)

115-124: Error handling correctly uses helper commands.

This properly uses New-Exception and New-ErrorRecord for public functions as clarified in previous review discussion. The ErrorId 'RSRSUEA0001' aligns with the expected pattern.

🧹 Nitpick comments (1)
tests/Integration/Commands/Set-SqlDscRSUnattendedExecutionAccount.Integration.Tests.ps1 (1)

36-89: Consider consolidating duplicated credential setup.

The same credential setup logic is repeated in all four contexts (lines 39-41, 53-55, 67-69, 81-83). While functional, consider using BeforeDiscovery or a shared BeforeAll at the Describe level to reduce duplication.

♻️ Potential consolidation
 Describe 'Set-SqlDscRSUnattendedExecutionAccount' {
+    BeforeAll {
+        $script:testUsername = '{0}\TestUnattendedAccount' -f (Get-ComputerName)
+        $script:testPassword = ConvertTo-SecureString -String 'P@ssw0rd123!' -AsPlainText -Force
+        $script:testCredential = [System.Management.Automation.PSCredential]::new($script:testUsername, $script:testPassword)
+    }
+
     Context 'When setting unattended execution account for SQL Server Reporting Services 2017' -Tag @('Integration_SQL2017_RS') {
         BeforeAll {
             $script:configuration = Get-SqlDscRSConfiguration -InstanceName 'SSRS' -ErrorAction 'Stop'
-
-            $script:testUsername = '{0}\TestUnattendedAccount' -f (Get-ComputerName)
-            $script:testPassword = ConvertTo-SecureString -String 'P@ssw0rd123!' -AsPlainText -Force
-            $script:testCredential = [System.Management.Automation.PSCredential]::new($script:testUsername, $script:testPassword)
         }
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a8e7371 and 4537edc.

📒 Files selected for processing (5)
  • source/Public/Remove-SqlDscRSUnattendedExecutionAccount.ps1
  • source/Public/Set-SqlDscRSUnattendedExecutionAccount.ps1
  • tests/Integration/Commands/Remove-SqlDscRSUnattendedExecutionAccount.Integration.Tests.ps1
  • tests/Integration/Commands/Set-SqlDscRSUnattendedExecutionAccount.Integration.Tests.ps1
  • tests/Unit/Public/Remove-SqlDscRSUnattendedExecutionAccount.Tests.ps1
🧰 Additional context used
📓 Path-based instructions (14)
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/Set-SqlDscRSUnattendedExecutionAccount.ps1
  • source/Public/Remove-SqlDscRSUnattendedExecutionAccount.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/Set-SqlDscRSUnattendedExecutionAccount.ps1
  • source/Public/Remove-SqlDscRSUnattendedExecutionAccount.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/Set-SqlDscRSUnattendedExecutionAccount.ps1
  • source/Public/Remove-SqlDscRSUnattendedExecutionAccount.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/Set-SqlDscRSUnattendedExecutionAccount.ps1
  • tests/Unit/Public/Remove-SqlDscRSUnattendedExecutionAccount.Tests.ps1
  • source/Public/Remove-SqlDscRSUnattendedExecutionAccount.ps1
  • tests/Integration/Commands/Set-SqlDscRSUnattendedExecutionAccount.Integration.Tests.ps1
  • tests/Integration/Commands/Remove-SqlDscRSUnattendedExecutionAccount.Integration.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/Set-SqlDscRSUnattendedExecutionAccount.ps1
  • tests/Unit/Public/Remove-SqlDscRSUnattendedExecutionAccount.Tests.ps1
  • source/Public/Remove-SqlDscRSUnattendedExecutionAccount.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/Set-SqlDscRSUnattendedExecutionAccount.ps1
  • tests/Unit/Public/Remove-SqlDscRSUnattendedExecutionAccount.Tests.ps1
  • source/Public/Remove-SqlDscRSUnattendedExecutionAccount.ps1
  • tests/Integration/Commands/Set-SqlDscRSUnattendedExecutionAccount.Integration.Tests.ps1
  • tests/Integration/Commands/Remove-SqlDscRSUnattendedExecutionAccount.Integration.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/Set-SqlDscRSUnattendedExecutionAccount.ps1
  • tests/Unit/Public/Remove-SqlDscRSUnattendedExecutionAccount.Tests.ps1
  • source/Public/Remove-SqlDscRSUnattendedExecutionAccount.ps1
  • tests/Integration/Commands/Set-SqlDscRSUnattendedExecutionAccount.Integration.Tests.ps1
  • tests/Integration/Commands/Remove-SqlDscRSUnattendedExecutionAccount.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/Unit/Public/Remove-SqlDscRSUnattendedExecutionAccount.Tests.ps1
  • tests/Integration/Commands/Set-SqlDscRSUnattendedExecutionAccount.Integration.Tests.ps1
  • tests/Integration/Commands/Remove-SqlDscRSUnattendedExecutionAccount.Integration.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/Remove-SqlDscRSUnattendedExecutionAccount.Tests.ps1
  • tests/Integration/Commands/Set-SqlDscRSUnattendedExecutionAccount.Integration.Tests.ps1
  • tests/Integration/Commands/Remove-SqlDscRSUnattendedExecutionAccount.Integration.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/Remove-SqlDscRSUnattendedExecutionAccount.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/Remove-SqlDscRSUnattendedExecutionAccount.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/Remove-SqlDscRSUnattendedExecutionAccount.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/Remove-SqlDscRSUnattendedExecutionAccount.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/Remove-SqlDscRSUnattendedExecutionAccount.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/Set-SqlDscRSUnattendedExecutionAccount.Integration.Tests.ps1
  • tests/Integration/Commands/Remove-SqlDscRSUnattendedExecutionAccount.Integration.Tests.ps1
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/Set-SqlDscRSUnattendedExecutionAccount.Integration.Tests.ps1
  • tests/Integration/Commands/Remove-SqlDscRSUnattendedExecutionAccount.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/Set-SqlDscRSUnattendedExecutionAccount.Integration.Tests.ps1
  • tests/Integration/Commands/Remove-SqlDscRSUnattendedExecutionAccount.Integration.Tests.ps1
**/tests/Integration/**/*.ps1

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

**/tests/Integration/**/*.ps1: Integration tests must use Connect-SqlDscDatabaseEngine for SQL Server DB session with correct CI credentials
Integration tests must use Disconnect-SqlDscDatabaseEngine after Connect-SqlDscDatabaseEngine

Files:

  • tests/Integration/Commands/Set-SqlDscRSUnattendedExecutionAccount.Integration.Tests.ps1
  • tests/Integration/Commands/Remove-SqlDscRSUnattendedExecutionAccount.Integration.Tests.ps1
🧠 Learnings (51)
📚 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 `PSCredential` for credentials

Applied to files:

  • source/Public/Set-SqlDscRSUnattendedExecutionAccount.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 be decorated with `[DscResource(RunAsCredential = 'Optional')]` or `[DscResource(RunAsCredential = 'Mandatory')]` based on requirements

Applied to files:

  • source/Public/Set-SqlDscRSUnattendedExecutionAccount.ps1
  • tests/Integration/Commands/Set-SqlDscRSUnattendedExecutionAccount.Integration.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:

  • source/Public/Set-SqlDscRSUnattendedExecutionAccount.ps1
  • tests/Unit/Public/Remove-SqlDscRSUnattendedExecutionAccount.Tests.ps1
  • tests/Integration/Commands/Set-SqlDscRSUnattendedExecutionAccount.Integration.Tests.ps1
  • tests/Integration/Commands/Remove-SqlDscRSUnattendedExecutionAccount.Integration.Tests.ps1
📚 Learning: 2026-01-15T17:58:20.966Z
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 2410
File: source/Public/Remove-SqlDscRSUnattendedExecutionAccount.ps1:115-125
Timestamp: 2026-01-15T17:58:20.966Z
Learning: In public functions under source/Public, use New-Exception and New-ErrorRecord for error handling. Do not use New-InvalidOperationException here; the New-*Exception helpers are intended for class-based resources under source/Classes/**/*.ps1. For public scripts, prefer creating standard exception objects or ErrorRecord via New-ErrorRecord to maintain consistent error reporting across public functions.

Applied to files:

  • source/Public/Set-SqlDscRSUnattendedExecutionAccount.ps1
  • source/Public/Remove-SqlDscRSUnattendedExecutionAccount.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/Set-SqlDscRSUnattendedExecutionAccount.ps1
  • source/Public/Remove-SqlDscRSUnattendedExecutionAccount.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/Set-SqlDscRSUnattendedExecutionAccount.ps1
  • source/Public/Remove-SqlDscRSUnattendedExecutionAccount.ps1
📚 Learning: 2025-09-28T13:49:31.541Z
Learnt from: dan-hughes
Repo: dsccommunity/DhcpServerDsc PR: 96
File: source/Modules/DhcpServerDsc.Common/Public/Get-ValidTimeSpan.ps1:36-39
Timestamp: 2025-09-28T13:49:31.541Z
Learning: In DSC Community guidelines, ErrorId parameters in New-TerminatingError calls are identifier strings that do not need localization - only the ErrorMessage parameter should use localized strings from $script:localizedData.

Applied to files:

  • source/Public/Set-SqlDscRSUnattendedExecutionAccount.ps1
  • source/Public/Remove-SqlDscRSUnattendedExecutionAccount.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/Set-SqlDscRSUnattendedExecutionAccount.ps1
  • source/Public/Remove-SqlDscRSUnattendedExecutionAccount.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/Set-SqlDscRSUnattendedExecutionAccount.ps1
  • source/Public/Remove-SqlDscRSUnattendedExecutionAccount.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-Error` for non-terminating errors with `-Message` (localized string), `-Category` (relevant error category), `-ErrorId` (unique ID), and `-TargetObject` (object causing error)

Applied to files:

  • source/Public/Set-SqlDscRSUnattendedExecutionAccount.ps1
  • source/Public/Remove-SqlDscRSUnattendedExecutionAccount.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/Set-SqlDscRSUnattendedExecutionAccount.ps1
  • source/Public/Remove-SqlDscRSUnattendedExecutionAccount.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/Set-SqlDscRSUnattendedExecutionAccount.ps1
  • source/Public/Remove-SqlDscRSUnattendedExecutionAccount.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/Set-SqlDscRSUnattendedExecutionAccount.ps1
  • source/Public/Remove-SqlDscRSUnattendedExecutionAccount.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/Remove-SqlDscRSUnattendedExecutionAccount.Tests.ps1
  • tests/Integration/Commands/Set-SqlDscRSUnattendedExecutionAccount.Integration.Tests.ps1
  • tests/Integration/Commands/Remove-SqlDscRSUnattendedExecutionAccount.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/Unit/Public/Remove-SqlDscRSUnattendedExecutionAccount.Tests.ps1
  • tests/Integration/Commands/Set-SqlDscRSUnattendedExecutionAccount.Integration.Tests.ps1
  • tests/Integration/Commands/Remove-SqlDscRSUnattendedExecutionAccount.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/Public/*.[Tt]ests.ps1 : Public commands: `tests/Unit/Public/{Name}.Tests.ps1`

Applied to files:

  • tests/Unit/Public/Remove-SqlDscRSUnattendedExecutionAccount.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/Remove-SqlDscRSUnattendedExecutionAccount.Tests.ps1
  • tests/Integration/Commands/Set-SqlDscRSUnattendedExecutionAccount.Integration.Tests.ps1
  • tests/Integration/Commands/Remove-SqlDscRSUnattendedExecutionAccount.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/Unit/Public/Remove-SqlDscRSUnattendedExecutionAccount.Tests.ps1
  • tests/Integration/Commands/Remove-SqlDscRSUnattendedExecutionAccount.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 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/Remove-SqlDscRSUnattendedExecutionAccount.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/Remove-SqlDscRSUnattendedExecutionAccount.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/Public/Remove-SqlDscRSUnattendedExecutionAccount.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/Remove-SqlDscRSUnattendedExecutionAccount.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/Unit/Public/Remove-SqlDscRSUnattendedExecutionAccount.Tests.ps1
  • tests/Integration/Commands/Set-SqlDscRSUnattendedExecutionAccount.Integration.Tests.ps1
  • tests/Integration/Commands/Remove-SqlDscRSUnattendedExecutionAccount.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 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/Remove-SqlDscRSUnattendedExecutionAccount.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/Unit/Public/Remove-SqlDscRSUnattendedExecutionAccount.Tests.ps1
  • tests/Integration/Commands/Set-SqlDscRSUnattendedExecutionAccount.Integration.Tests.ps1
  • tests/Integration/Commands/Remove-SqlDscRSUnattendedExecutionAccount.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 : Use `$PSDefaultParameterValues` only for Pester commands (`Describe`, `Context`, `It`, `Mock`, `Should`, `InModuleScope`)

Applied to files:

  • tests/Unit/Public/Remove-SqlDscRSUnattendedExecutionAccount.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} : For state-changing functions, use `SupportsShouldProcess` attribute with `ConfirmImpact` set to 'Low', 'Medium', or 'High' depending on risk

Applied to files:

  • source/Public/Remove-SqlDscRSUnattendedExecutionAccount.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} : Include a `Force` parameter for functions that use `$PSCmdlet.ShouldContinue` or `$PSCmdlet.ShouldProcess`

Applied to files:

  • source/Public/Remove-SqlDscRSUnattendedExecutionAccount.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/Remove-SqlDscRSUnattendedExecutionAccount.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/Remove-SqlDscRSUnattendedExecutionAccount.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/Remove-SqlDscRSUnattendedExecutionAccount.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/Remove-SqlDscRSUnattendedExecutionAccount.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/Remove-SqlDscRSUnattendedExecutionAccount.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/Remove-SqlDscRSUnattendedExecutionAccount.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/Set-SqlDscRSUnattendedExecutionAccount.Integration.Tests.ps1
  • tests/Integration/Commands/Remove-SqlDscRSUnattendedExecutionAccount.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/Integration/Resources/*.Integration.Tests.ps1 : Location for resource integration tests: `tests/Integration/Resources/{ResourceName}.Integration.Tests.ps1`

Applied to files:

  • tests/Integration/Commands/Set-SqlDscRSUnattendedExecutionAccount.Integration.Tests.ps1
  • tests/Integration/Commands/Remove-SqlDscRSUnattendedExecutionAccount.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 : Call commands with `-Force` parameter where applicable in integration tests to avoid prompting

Applied to files:

  • tests/Integration/Commands/Set-SqlDscRSUnattendedExecutionAccount.Integration.Tests.ps1
  • tests/Integration/Commands/Remove-SqlDscRSUnattendedExecutionAccount.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/Integration/Commands/*.Integration.Tests.ps1 : Location for command integration tests: `tests/Integration/Commands/{CommandName}.Integration.Tests.ps1`

Applied to files:

  • tests/Integration/Commands/Set-SqlDscRSUnattendedExecutionAccount.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/Set-SqlDscRSUnattendedExecutionAccount.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 : Define `-ForEach` variables in `BeforeDiscovery` (close to usage)

Applied to files:

  • tests/Integration/Commands/Set-SqlDscRSUnattendedExecutionAccount.Integration.Tests.ps1
  • tests/Integration/Commands/Remove-SqlDscRSUnattendedExecutionAccount.Integration.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/Set-SqlDscRSUnattendedExecutionAccount.Integration.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/Integration/Commands/Set-SqlDscRSUnattendedExecutionAccount.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 : Use `-ErrorAction 'Stop'` on commands in integration tests so failures surface immediately

Applied to files:

  • tests/Integration/Commands/Remove-SqlDscRSUnattendedExecutionAccount.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 tests must cover all scenarios and code paths

Applied to files:

  • tests/Integration/Commands/Remove-SqlDscRSUnattendedExecutionAccount.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 : Keep results and assertions in same `It` block

Applied to files:

  • tests/Integration/Commands/Remove-SqlDscRSUnattendedExecutionAccount.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 : Assertions only in `It` blocks

Applied to files:

  • tests/Integration/Commands/Remove-SqlDscRSUnattendedExecutionAccount.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 : Use nested `Context` blocks for complex scenarios

Applied to files:

  • tests/Integration/Commands/Remove-SqlDscRSUnattendedExecutionAccount.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 : Tested entity must be called from within the `It` blocks

Applied to files:

  • tests/Integration/Commands/Remove-SqlDscRSUnattendedExecutionAccount.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 : `-ForEach` allowed on `Context` and `It` blocks

Applied to files:

  • tests/Integration/Commands/Remove-SqlDscRSUnattendedExecutionAccount.Integration.Tests.ps1
📚 Learning: 2025-10-11T08:18:26.062Z
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 2300
File: tests/Unit/DSC_SqlAGDatabase.Tests.ps1:22-22
Timestamp: 2025-10-11T08:18:26.062Z
Learning: In unit test files (tests/[Uu]nit/**/*.[Tt]ests.ps1), when DscResource.Test module dependency is not found during BeforeDiscovery setup, the error message should instruct users to run ".\build.ps1 -Tasks noop" (not "build") because the noop task is designed for quick test environment setup. The build task is more extensive and unnecessary when tests run in a separate process, as the module should already be built before running tests.

Applied to files:

  • tests/Integration/Commands/Remove-SqlDscRSUnattendedExecutionAccount.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 : Avoid unnecessary remove/recreate cycles

Applied to files:

  • tests/Integration/Commands/Remove-SqlDscRSUnattendedExecutionAccount.Integration.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 (7)
source/Public/Set-SqlDscRSUnattendedExecutionAccount.ps1 (2)

79-101: LGTM! Well-structured public command declaration.

The function follows the correct naming convention (Set-SqlDsc{Noun}), includes proper CmdletBinding with SupportsShouldProcess and ConfirmImpact = 'Medium', and correctly declares the OutputType. The Force parameter is appropriately included for bypassing confirmation.


139-152: Error handling and secure memory cleanup look correct.

The error handling now properly uses New-Exception and New-ErrorRecord for public functions (per learnings). The finally block correctly zeroes the BSTR memory to prevent password exposure. This addresses the past review feedback.

source/Public/Remove-SqlDscRSUnattendedExecutionAccount.ps1 (1)

69-87: LGTM! Public command follows conventions.

The function declaration properly follows the Remove-SqlDsc{Noun} naming convention with appropriate CmdletBinding attributes and parameter definitions.

tests/Unit/Public/Remove-SqlDscRSUnattendedExecutionAccount.Tests.ps1 (1)

1-44: LGTM! Test setup follows guidelines.

The test file includes the required setup block with BeforeDiscovery, BeforeAll (with $env:SqlServerDscCI = $true), and AfterAll (removing the environment variable). PSDefaultParameterValues are correctly configured.

tests/Integration/Commands/Remove-SqlDscRSUnattendedExecutionAccount.Integration.Tests.ps1 (2)

40-49: LGTM! Test context now includes the It block.

The Integration_SQL2017_RS context now correctly includes an It block that tests the removal operation. This addresses the past review feedback about the missing test.


34-80: Integration tests follow guidelines.

The test file correctly uses -Force to avoid prompts and -ErrorAction 'Stop' to surface failures immediately. The setup block follows the required pattern, and all four contexts (SQL2017_RS, SQL2019_RS, SQL2022_RS, PowerBI) are properly structured.

tests/Integration/Commands/Set-SqlDscRSUnattendedExecutionAccount.Integration.Tests.ps1 (1)

34-47: LGTM! Integration test structure is correct.

The test uses Get-ComputerName for CI environment compatibility, -Force to avoid prompts, and -ErrorAction 'Stop' to surface failures. While ConvertTo-SecureString -AsPlainText is used, this is acceptable in test code (the guideline applies to production code).

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

…and Set-SqlDscRSUnattendedExecutionAccount for consistency; update test cases to reflect new error IDs.
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: 2

🤖 Fix all issues with AI agents
In `@source/en-US/SqlServerDsc.strings.psd1`:
- Around line 914-920: The failed-message string ID for
Set-SqlDscRSUnattendedExecutionAccount uses the incorrect prefix "(RSSUEA0001)";
update it to use the correct prefix "(SSRSUEA0001)" to match the function name
convention (S=Set, S=Sql, RS, UEA=UnattendedExecutionAccount) — specifically
change the suffix in Set_SqlDscRSUnattendedExecutionAccount_FailedToSet from
RSSUEA0001 to SSRSUEA0001 so it aligns with other entries (e.g.,
Remove-SqlDscRSUnattendedExecutionAccount uses RSRSUEA).

In `@source/Public/Set-SqlDscRSUnattendedExecutionAccount.ps1`:
- Around line 139-148: The catch block creates an error record with ErrorId
'SSRSUEA0001' which doesn't match the localized string suffix '(RSSUEA0001)';
update the ErrorId used in the New-ErrorRecord call (where $exception is created
and $errorRecord is assigned) from 'SSRSUEA0001' to 'RSSUEA0001' so the ErrorId
and localized string suffix are consistent before calling
$PSCmdlet.ThrowTerminatingError($errorRecord).
🧹 Nitpick comments (1)
tests/Unit/Public/Remove-SqlDscRSUnattendedExecutionAccount.Tests.ps1 (1)

107-121: Consider adding -ParameterFilter for completeness.

The Force parameter test verifies invocation count but doesn't validate that the correct method is called. For consistency with the test at lines 78-80, consider adding the parameter filter.

♻️ Suggested improvement
         It 'Should remove unattended execution account without confirmation' {
             $mockCimInstance | Remove-SqlDscRSUnattendedExecutionAccount -Force

-            Should -Invoke -CommandName Invoke-RsCimMethod -Exactly -Times 1
+            Should -Invoke -CommandName Invoke-RsCimMethod -ParameterFilter {
+                $MethodName -eq 'RemoveUnattendedExecutionAccount'
+            } -Exactly -Times 1
         }
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4537edc and d833508.

📒 Files selected for processing (5)
  • source/Public/Remove-SqlDscRSUnattendedExecutionAccount.ps1
  • source/Public/Set-SqlDscRSUnattendedExecutionAccount.ps1
  • source/en-US/SqlServerDsc.strings.psd1
  • tests/Unit/Public/Remove-SqlDscRSUnattendedExecutionAccount.Tests.ps1
  • tests/Unit/Public/Set-SqlDscRSUnattendedExecutionAccount.Tests.ps1
🚧 Files skipped from review as they are similar to previous changes (2)
  • tests/Unit/Public/Set-SqlDscRSUnattendedExecutionAccount.Tests.ps1
  • source/Public/Remove-SqlDscRSUnattendedExecutionAccount.ps1
🧰 Additional context used
📓 Path-based instructions (13)
**/*.[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/Remove-SqlDscRSUnattendedExecutionAccount.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/Remove-SqlDscRSUnattendedExecutionAccount.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/Remove-SqlDscRSUnattendedExecutionAccount.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/Remove-SqlDscRSUnattendedExecutionAccount.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/Unit/Public/Remove-SqlDscRSUnattendedExecutionAccount.Tests.ps1
  • source/en-US/SqlServerDsc.strings.psd1
  • source/Public/Set-SqlDscRSUnattendedExecutionAccount.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/Remove-SqlDscRSUnattendedExecutionAccount.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/Remove-SqlDscRSUnattendedExecutionAccount.Tests.ps1
**/Public/**/*.ps1

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

Public commands must follow the naming format {Verb}-SqlDsc{Noun}

Files:

  • tests/Unit/Public/Remove-SqlDscRSUnattendedExecutionAccount.Tests.ps1
  • source/Public/Set-SqlDscRSUnattendedExecutionAccount.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/Remove-SqlDscRSUnattendedExecutionAccount.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/Unit/Public/Remove-SqlDscRSUnattendedExecutionAccount.Tests.ps1
  • source/en-US/SqlServerDsc.strings.psd1
  • source/Public/Set-SqlDscRSUnattendedExecutionAccount.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:

  • tests/Unit/Public/Remove-SqlDscRSUnattendedExecutionAccount.Tests.ps1
  • source/en-US/SqlServerDsc.strings.psd1
  • source/Public/Set-SqlDscRSUnattendedExecutionAccount.ps1
source/en-US/*.strings.psd1

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

source/en-US/*.strings.psd1: Store command/function localized strings in source/en-US/{MyModuleName}.strings.psd1 files
Store class resource localized strings in source/en-US/{ResourceClassName}.strings.psd1 files
Use Key Naming Pattern format: Verb_FunctionName_Action with underscore separators (e.g., Get_Database_ConnectingToDatabase)
Format localized strings using ConvertFrom-StringData with placeholder syntax: KeyName = Message with {0} placeholder. (PREFIX0001)
Prefix string IDs with an acronym derived from the first letter of each word in the class or function name (e.g., SqlSetup → SS, Get-SqlDscDatabase → GSDD), followed by sequential numbers starting from 0001

Files:

  • source/en-US/SqlServerDsc.strings.psd1
**/*.psd1

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

Don't use NestedModules for shared commands without RootModule in module manifest

Files:

  • source/en-US/SqlServerDsc.strings.psd1
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/Set-SqlDscRSUnattendedExecutionAccount.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/Set-SqlDscRSUnattendedExecutionAccount.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/Set-SqlDscRSUnattendedExecutionAccount.ps1
🧠 Learnings (42)
📓 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/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/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.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/Remove-SqlDscRSUnattendedExecutionAccount.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/Remove-SqlDscRSUnattendedExecutionAccount.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/Remove-SqlDscRSUnattendedExecutionAccount.Tests.ps1
  • source/Public/Set-SqlDscRSUnattendedExecutionAccount.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 : Avoid unnecessary remove/recreate cycles

Applied to files:

  • tests/Unit/Public/Remove-SqlDscRSUnattendedExecutionAccount.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/Remove-SqlDscRSUnattendedExecutionAccount.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/Remove-SqlDscRSUnattendedExecutionAccount.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/Remove-SqlDscRSUnattendedExecutionAccount.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/Unit/Public/Remove-SqlDscRSUnattendedExecutionAccount.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/Remove-SqlDscRSUnattendedExecutionAccount.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/Public/Remove-SqlDscRSUnattendedExecutionAccount.Tests.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:

  • tests/Unit/Public/Remove-SqlDscRSUnattendedExecutionAccount.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/Remove-SqlDscRSUnattendedExecutionAccount.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/Remove-SqlDscRSUnattendedExecutionAccount.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 : Avoid using `ExpectedMessage` parameter for `Should -Throw` assertions in integration tests

Applied to files:

  • tests/Unit/Public/Remove-SqlDscRSUnattendedExecutionAccount.Tests.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:

  • tests/Unit/Public/Remove-SqlDscRSUnattendedExecutionAccount.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 : Use `-ErrorAction 'Stop'` on commands in integration tests so failures surface immediately

Applied to files:

  • tests/Unit/Public/Remove-SqlDscRSUnattendedExecutionAccount.Tests.ps1
📚 Learning: 2025-10-19T10:33:22.772Z
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 2309
File: tests/Integration/Commands/Initialize-SqlDscRebuildDatabase.Integration.Tests.ps1:132-148
Timestamp: 2025-10-19T10:33:22.772Z
Learning: In SqlServerDsc integration tests, when connecting via Connect-SqlDscDatabaseEngine using a local Windows account (e.g., 'SqlAdmin'), use the plain username format without computer/domain prefix. This is Windows Authentication with a local account. The NetBIOS format (e.g., 'COMPUTER\SqlAdmin') is only used for SqlSysAdminAccounts during SQL Server setup/rebuild and will throw an exception if used with Connect-SqlDscDatabaseEngine for local Windows accounts.

Applied to files:

  • tests/Unit/Public/Remove-SqlDscRSUnattendedExecutionAccount.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 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/Remove-SqlDscRSUnattendedExecutionAccount.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/Unit/Public/Remove-SqlDscRSUnattendedExecutionAccount.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/Remove-SqlDscRSUnattendedExecutionAccount.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/Remove-SqlDscRSUnattendedExecutionAccount.Tests.ps1
📚 Learning: 2025-12-10T20:07:36.848Z
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 2367
File: source/en-US/SqlServerDsc.strings.psd1:489-498
Timestamp: 2025-12-10T20:07:36.848Z
Learning: Do not renumber localization keys to make them sequential when gaps exist in error codes (e.g., RSDD0001 vs RSDD0003). Preserve existing keys. QA tests should already guard against missing or extra localization string keys, so avoid altering the numbering just to achieve contiguity. If modifications touch localization strings, ensure tests reflect the current keys and document any intentional gaps.

Applied to files:

  • source/en-US/SqlServerDsc.strings.psd1
📚 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/en-US/*.strings.psd1 : Prefix string IDs with an acronym derived from the first letter of each word in the class or function name (e.g., SqlSetup → SS, Get-SqlDscDatabase → GSDD), followed by sequential numbers starting from 0001

Applied to files:

  • source/en-US/SqlServerDsc.strings.psd1
📚 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/en-US/SqlServerDsc.strings.psd1
📚 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/**/en-US/DSC_*.strings.psd1 : In `.strings.psd1` files, use underscores as word separators in localized string key names for multi-word keys

Applied to files:

  • source/en-US/SqlServerDsc.strings.psd1
📚 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/**/en-US/DSC_*.strings.psd1 : Name localized strings file as `DSC_<ResourceName>.strings.psd1` in the `en-US` folder

Applied to files:

  • source/en-US/SqlServerDsc.strings.psd1
📚 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 : Import localized strings using `Get-LocalizedData` at the module top level

Applied to files:

  • source/en-US/SqlServerDsc.strings.psd1
📚 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} : `$PSCmdlet.ShouldProcess` must use the required pattern with `$descriptionMessage`, `$confirmationMessage`, and `$captionMessage`

Applied to files:

  • source/en-US/SqlServerDsc.strings.psd1
📚 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 localized strings for all messages including Write-Verbose, Write-Error, and other messaging commands

Applied to files:

  • source/en-US/SqlServerDsc.strings.psd1
📚 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 `PSCredential` for credentials

Applied to files:

  • source/Public/Set-SqlDscRSUnattendedExecutionAccount.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 be decorated with `[DscResource(RunAsCredential = 'Optional')]` or `[DscResource(RunAsCredential = 'Mandatory')]` based on requirements

Applied to files:

  • source/Public/Set-SqlDscRSUnattendedExecutionAccount.ps1
📚 Learning: 2026-01-15T17:58:20.966Z
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 2410
File: source/Public/Remove-SqlDscRSUnattendedExecutionAccount.ps1:115-125
Timestamp: 2026-01-15T17:58:20.966Z
Learning: In public functions under source/Public, use New-Exception and New-ErrorRecord for error handling. Do not use New-InvalidOperationException here; the New-*Exception helpers are intended for class-based resources under source/Classes/**/*.ps1. For public scripts, prefer creating standard exception objects or ErrorRecord via New-ErrorRecord to maintain consistent error reporting across public functions.

Applied to files:

  • source/Public/Set-SqlDscRSUnattendedExecutionAccount.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/Set-SqlDscRSUnattendedExecutionAccount.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/Set-SqlDscRSUnattendedExecutionAccount.ps1
📚 Learning: 2025-09-28T13:49:31.541Z
Learnt from: dan-hughes
Repo: dsccommunity/DhcpServerDsc PR: 96
File: source/Modules/DhcpServerDsc.Common/Public/Get-ValidTimeSpan.ps1:36-39
Timestamp: 2025-09-28T13:49:31.541Z
Learning: In DSC Community guidelines, ErrorId parameters in New-TerminatingError calls are identifier strings that do not need localization - only the ErrorMessage parameter should use localized strings from $script:localizedData.

Applied to files:

  • source/Public/Set-SqlDscRSUnattendedExecutionAccount.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/Set-SqlDscRSUnattendedExecutionAccount.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/Set-SqlDscRSUnattendedExecutionAccount.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-Error` for non-terminating errors with `-Message` (localized string), `-Category` (relevant error category), `-ErrorId` (unique ID), and `-TargetObject` (object causing error)

Applied to files:

  • source/Public/Set-SqlDscRSUnattendedExecutionAccount.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/Set-SqlDscRSUnattendedExecutionAccount.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/Set-SqlDscRSUnattendedExecutionAccount.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/Set-SqlDscRSUnattendedExecutionAccount.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 (10)
tests/Unit/Public/Remove-SqlDscRSUnattendedExecutionAccount.Tests.ps1 (5)

1-44: LGTM! Test setup follows the required template correctly.

The BeforeDiscovery, BeforeAll, and AfterAll blocks correctly implement all required patterns including:

  • DscResource.Test module import with proper error handling
  • $env:SqlServerDscCI = $true setup and teardown
  • PSDefaultParameterValues configuration for Pester commands

46-64: LGTM! Parameter set validation follows the required template.


66-88: LGTM! Good separation of concerns in test assertions.

The two It blocks appropriately test distinct behaviors: method invocation and return value. Mock setup correctly omits -MockWith for null returns per guidelines.


123-137: LGTM! Error handling test correctly validates terminating error.

The ErrorId RSRSUEA0001 matches the implementation. The mock correctly simulates a CIM method failure scenario.


139-169: LGTM! WhatIf and parameter input scenarios well covered.

Both contexts properly validate expected behavior: WhatIf prevents method invocation, and configuration parameter input works correctly.

source/Public/Set-SqlDscRSUnattendedExecutionAccount.ps1 (3)

1-78: LGTM! Well-documented comment-based help.

The help includes SYNOPSIS, DESCRIPTION, PARAMETER, INPUTS, OUTPUTS, NOTES, and LINK sections with multiple examples covering pipeline usage, Force parameter, and PassThru scenarios.


79-101: LGTM! Function declaration follows DSC Community guidelines.

Proper use of CmdletBinding, SupportsShouldProcess, ConfirmImpact, OutputType, and PSCredential for credentials.


104-159: LGTM! Process block implementation is solid.

  • Force parameter pattern correctly implemented
  • ShouldProcess uses the required three-parameter pattern with localized strings
  • SecureString conversion with proper BSTR cleanup in finally block
  • Error handling follows public function guidelines using New-Exception and New-ErrorRecord
  • Write-Verbose correctly placed outside the ShouldProcess block

Based on learnings, the use of New-Exception and New-ErrorRecord (instead of New-InvalidOperationException) is correct for public functions.

source/en-US/SqlServerDsc.strings.psd1 (2)

306-306: LGTM! Retry string follows existing pattern.

The new string for retry logic uses the correct prefix GSRSCD matching other Get-SqlDscRSConfiguration strings, with sequential numbering 0005.


922-928: LGTM! Remove function strings are correctly formatted.

The string ID prefix RSRSUEA correctly follows the first-letter pattern for Remove-SqlDscRSUnattendedExecutionAccount. All required ShouldProcess strings (Description, Confirmation, Caption) and error string are present.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs review The pull request needs a code review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant