Skip to content

Conversation

@dan-hughes
Copy link
Contributor

@dan-hughes dan-hughes commented Oct 15, 2025

Pull Request (PR) description

Migrate tests to Pester 5.

This Pull Request (PR) fixes the following issues

Task list

  • Added an entry to the change log under the Unreleased section of the file CHANGELOG.md.
    Entry should say what was changed and how that affects users (if applicable), and
    reference the issue being resolved (if applicable).
  • Resource documentation added/updated in README.md.
  • Resource parameter descriptions added/updated in README.md, schema.mof and comment-based
    help.
  • Comment-based help added/updated.
  • Localization strings added/updated in all localization files as appropriate.
  • Examples appropriately added/updated.
  • Unit tests added/updated. See DSC Community Testing Guidelines.
  • Integration tests added/updated (where possible). See DSC Community Testing Guidelines.
  • New/changed code adheres to DSC Community Style Guidelines.

This change is Reviewable

@coderabbitai
Copy link

coderabbitai bot commented Oct 15, 2025

Walkthrough

Reworks module loading/localization, migrates tests to Pester 5 and PowerShell Core, updates CI/build/tooling and analyzer settings, introduces a common submodule with OS helpers, changes many DSC resource parameter types to explicit System.* types, replaces legacy test suites with new Pester v5 suites, and adjusts error/validation flows.

Changes

Cohort / File(s) Summary
Editor / CI / Build config
.vscode/settings.json, \.vscode/analyzersettings.psd1, azure-pipelines.yml, build.yaml, RequiredModules.psd1, Resolve-Dependency.psd1, CHANGELOG.md
Add Pester/editor settings and CodeLens options, change analyzer paths/rules, update RequiredModules (Pester → latest, add Indented.ScriptAnalyzerRules), enable UseModuleFast, switch CI unit test step to pwsh, expand build Pester/coverage configs, and record Unreleased changelog entries.
Common module scaffold & manifests
source/Modules/xRemoteDesktopSessionHost.Common/xRemoteDesktopSessionHost.Common.psd1, source/Modules/xRemoteDesktopSessionHost.Common/prefix.ps1, source/Modules/xRemoteDesktopSessionHost.Common/en-US/...
Add new common submodule layout and prefix loader, change RootModule filename, add en‑US localization file, and move/add OS helper functions into the new common module manifest.
Legacy common module removal
source/Modules/xRemoteDesktopSessionHostCommon.psm1
Remove legacy monolithic functions (Get-LocalizedData, Get-xRemoteDesktopSessionHostOsVersion, Test-xRemoteDesktopSessionHostOsRequirement) from the old psm1.
Localization assets
source/Modules/en-US/xRemoteDesktopSessionHost.Common.strings.psd1, source/en-US/xRemoteDesktopSessionHost.strings.psd1, source/Modules/en-US/...
Add new en‑US .strings.psd1 files and remove the older localized PSD1 block for the common module.
New public helpers
source/Modules/xRemoteDesktopSessionHost.Common/Public/Get-xRemoteDesktopSessionHostOsVersion.ps1, source/Modules/xRemoteDesktopSessionHost.Common/Public/Test-xRemoteDesktopSessionHostOsRequirement.ps1
Add OS-version helper and an OS-requirement test function.
DSC resources — import/assert refactor & typing changes
source/DSCResources/.../MSFT_xRDCertificateConfiguration/MSFT_xRDCertificateConfiguration.psm1, .../MSFT_xRDConnectionBrokerHAMode/...psm1, .../MSFT_xRDGatewayConfiguration/...psm1, .../MSFT_xRDLicenseConfiguration/...psm1, .../MSFT_xRDRemoteApp/...psm1, .../MSFT_xRDServer/...psm1, .../MSFT_xRDSessionCollection/...psm1, .../MSFT_xRDSessionCollectionConfiguration/...psm1, .../MSFT_xRDSessionDeployment/...psm1
Replace static Import-Module paths with computed modulePath imports for xRemoteDesktopSessionHost.Common and DscResource.Common; replace Import-Module RemoteDesktop with Assert-Module -ModuleName 'RemoteDesktop' -ImportModule; convert many parameter/return types to explicit [System.*]; use parameter splatting and Test-DscParameterState in Test-TargetResource implementations; adjust error handling/return semantics.
Unit tests — additions (Pester 5)
tests/Unit/*/*.Tests.ps1 (e.g., MSFT_xRDCertificateConfiguration.Tests.ps1, MSFT_xRDConnectionBrokerHAMode.Tests.ps1, MSFT_xRDGatewayConfiguration.Tests.ps1, MSFT_xRDLicenseConfiguration.Tests.ps1, MSFT_xRDRemoteApp.Tests.ps1, MSFT_xRDServer.Tests.ps1, MSFT_xRDSessionCollection.Tests.ps1, MSFT_xRDSessionCollectionConfiguration.Tests.ps1, MSFT_xRDSessionDeployment.Tests.ps1, xRemoteDesktopSessionHost.Common/...Tests.ps1)
Add new Pester v5-style test suites with setup/teardown harnesses, mocks, and coverage for Get-/Set-/Test-TargetResource paths.
Unit tests — removals (legacy Pester 4)
tests/Unit/*/*.tests.ps1 (many deleted legacy files, e.g., tests/Unit/MSFT_xRD*.tests.ps1, tests/Unit/xRemoteDesktopSessionHost.tests.ps1, etc.)
Remove legacy Pester v4-style test suites (old .tests.ps1) across multiple DSC resources; replaced by new .Tests.ps1 suites.
Stubs / test harness adjustments
tests/Unit/**/Stubs/*, other test-support files (implicit)
Update test harness/stub usage across new tests (mocks, InModuleScope, discovery guards) — many test files reference/assume updated stubs and test initialization flows.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant DSC as DSC Engine
  participant Res as Resource (.psm1)
  participant Common as xRemoteDesktopSessionHost.Common
  participant RD as RemoteDesktop Module

  User->>DSC: Invoke Get/Test/Set-TargetResource
  DSC->>Res: Call *-TargetResource(params)
  Res->>Res: Run early checks (OS, param validation)
  Res->>Common: Import computed common modules (modulePath)
  Res->>RD: Assert-Module 'RemoteDesktop' -ImportModule
  alt Assert succeeds
    Res->>RD: Call RD cmdlets (Get-/Set-/Add-/Remove-RD*)
    RD-->>Res: Return results
    Res-->>DSC: Return hashtable / boolean
  else Assert fails
    Res-->>DSC: Throw missing-module error
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Potential review hotspots:

  • Resources with broad signature/type changes and new Test-DscParameterState usage (e.g., MSFT_xRDGatewayConfiguration, MSFT_xRDSessionCollectionConfiguration).
  • Consistency and correctness of computed modulePath and the Import-Module / Assert-Module pattern across all DSC resources.
  • New Pester v5 test suites — verify mocks/stubs, discovery guards, and that removed legacy tests' coverage is preserved.

Possibly related PRs

Pre-merge checks

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Title Check ✅ Passed The PR title "Migrate Tests to Pester 5" directly and clearly summarizes the primary change in the changeset. The bulk of the modifications involve migrating old Pester 4-format test files (.tests.ps1) to Pester 5 format (.Tests.ps1) with updated test scaffolding (BeforeDiscovery, BeforeAll, AfterAll blocks), updating test infrastructure configurations, and modernizing the testing pipeline. A developer reviewing the repository history would immediately understand that this PR addresses a test framework migration. The title is concise, specific, and accurately reflects the main objective of the work.
Linked Issues Check ✅ Passed The code changes align with the objectives specified in the linked issues. For issue #119 (Migrate tests to Pester 5), the changeset removes old Pester 4-format test files (.tests.ps1) and introduces new Pester 5-compliant test files (.Tests.ps1) with proper structure, updates RequiredModules.psd1 to Pester 'latest', configures Pester settings in .vscode/settings.json and build.yaml, and updates the pipeline to use pwsh. For issue #124 (xRDSessionDeployment improvements), MSFT_xRDSessionDeployment.psm1 is updated to support removal of departed session hosts and Web Access servers, and the CHANGELOG documents these changes. The resource modernizations (parameter type standardization to System.String, adoption of Test-DscParameterState) support improved test compatibility with Pester 5 and align with DSC Community Style Guidelines referenced in both issues.
Out of Scope Changes Check ✅ Passed The changeset contains primarily in-scope modifications that support the stated objectives of test migration (#119) and xRDSessionDeployment improvements (#124). All changes are documented in the CHANGELOG.md as "Unreleased" entries, including test migration, module restructuring (renaming xRemoteDesktopSessionHostCommon to xRemoteDesktopSessionHost.Common), and resource parameter type standardization. The DSC resource modifications (parameter type changes to System.String, adoption of Test-DscParameterState, Assert-Module patterns, and module import refactoring) represent necessary supporting changes to modernize resources alongside the Pester 5 migration and enable better test compatibility. Build configuration updates and infrastructure changes (build.yaml, azure-pipelines.yml, Resolve-Dependency.psd1) directly support the test framework migration. No changes appear to be unrelated to the documented objectives or inconsistent with DSC Community Style Guidelines.
Description Check ✅ Passed The PR description is clearly related to the changeset. It explicitly states "Migrate tests to Pester 5," references the linked issue #119 which is titled "Migrate tests to Pester 5," and marks the task list items as completed including CHANGELOG entries, unit tests, and integration tests. The description also references issue #124 regarding xRDSessionDeployment improvements. The description is sufficiently informative and directly connects to the work being performed in the changeset, which consists primarily of test file migrations, test infrastructure updates, and supporting resource modernizations.

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between eb1a0a2 and 3318ec3.

📒 Files selected for processing (2)
  • source/Modules/xRemoteDesktopSessionHost.Common/Public/Get-xRemoteDesktopSessionHostOsVersion.ps1 (1 hunks)
  • source/Modules/xRemoteDesktopSessionHost.Common/Public/Test-xRemoteDesktopSessionHostOsRequirement.ps1 (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • source/Modules/xRemoteDesktopSessionHost.Common/Public/Test-xRemoteDesktopSessionHostOsRequirement.ps1
🧰 Additional context used
📓 Path-based instructions (3)
**

⚙️ 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
  • 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/Modules/xRemoteDesktopSessionHost.Common/Public/Get-xRemoteDesktopSessionHostOsVersion.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 (one per line) with a 1‑line description...

Files:

  • source/Modules/xRemoteDesktopSessionHost.Common/Public/Get-xRemoteDesktopSessionHostOsVersion.ps1
source/**/*.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/Modules/xRemoteDesktopSessionHost.Common/Public/Get-xRemoteDesktopSessionHostOsVersion.ps1
🧠 Learnings (11)
📓 Common learnings
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-10-26T13:27:07.728Z
Learning: Applies to **/*.[Tt]ests.ps1 : Use Pester v5 syntax only
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.
Learnt from: dan-hughes
Repo: dsccommunity/UpdateServicesDsc PR: 85
File: source/en-US/UpdateServicesDsc.strings.psd1:1-2
Timestamp: 2025-10-04T21:33:23.022Z
Learning: In UpdateServicesDsc (and similar DSC modules), the module-level localization file (source/en-US/<ModuleName>.strings.psd1) can be empty when DSC resources have their own localization files in source/DSCResources/<ResourceName>/en-US/DSC_<ResourceName>.strings.psd1. Automated tests verify localization completeness for resources. Don't flag empty module-level localization files as issues when resources have separate localization.
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-unit-tests.instructions.md:0-0
Timestamp: 2025-09-16T16:34:44.689Z
Learning: Applies to tests/[Uu]nit/**/*.[Tt]ests.ps1 : Include the exact Pester setup block before Describe: SuppressMessage attribute with param (); BeforeDiscovery to ensure DscResource.Test is available (fallback to build.ps1 -Tasks 'noop') and Import-Module; BeforeAll to set $script:moduleName, import the module, and set PSDefaultParameterValues for InModuleScope/Mock/Should; AfterAll to remove those defaults and unload the tested module
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 2150
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:35-35
Timestamp: 2025-08-28T15:44:12.628Z
Learning: The repository uses RequiredModules.psd1 to specify Pester version requirements with RequiredVersion = 'latest', which ensures compatibility with Should -Invoke syntax (requires Pester 5.4+).
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-09-12T13:20:57.155Z
Learning: Applies to source/DSCResources/**/*.psm1 : Use localized strings for all messages (e.g., Write-Verbose, Write-Error)
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 2300
File: tests/Unit/DSC_SqlAGDatabase.Tests.ps1:22-22
Timestamp: 2025-10-11T08:35:56.141Z
Learning: In DSC Community projects, when writing error messages for missing DscResource.Test module dependency in unit test files (tests/[Uu]nit/**/*.[Tt]ests.ps1), the policy is: new code should instruct users to run ".\build.ps1 -Tasks noop" for quick test environment setup; existing code using ".\build.ps1 -Tasks build" is acceptable but slower since it also builds the project. The `noop` task is preferred as it assumes the module is already built before running tests, especially when tests run in a separate process.
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-09-12T13:20:57.155Z
Learning: Applies to source/DSCResources/**/*.psm1 : Import localized strings at the top of the module using Get-LocalizedData
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 2150
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:35-35
Timestamp: 2025-08-28T15:44:12.628Z
Learning: The SqlServerDsc repository uses RequiredModules.psd1 to specify Pester with Version = 'latest' and AllowPrerelease = $true, ensuring the latest Pester version (well beyond 5.4) is available, which supports Should -Invoke syntax and other modern Pester features.
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-10-26T13:27:07.728Z
Learning: Applies to **/*.[Tt]ests.ps1 : Avoid unnecessary remove/recreate cycles in tests
📚 Learning: 2025-10-26T13:28:23.439Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-10-26T13:28:23.439Z
Learning: Applies to **/*.{ps1,psm1} : Always add comment-based help to all functions and scripts

Applied to files:

  • source/Modules/xRemoteDesktopSessionHost.Common/Public/Get-xRemoteDesktopSessionHostOsVersion.ps1
📚 Learning: 2025-09-12T13:20:14.850Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-class-resource.instructions.md:0-0
Timestamp: 2025-09-12T13:20:14.850Z
Learning: Applies to source/[cC]lasses/**/*.ps1 : Comment-based help .DESCRIPTION must include '## Requirements'

Applied to files:

  • source/Modules/xRemoteDesktopSessionHost.Common/Public/Get-xRemoteDesktopSessionHostOsVersion.ps1
📚 Learning: 2025-10-26T13:28:23.439Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-10-26T13:28:23.439Z
Learning: Applies to **/*.{ps1,psm1} : Comment-based help must include SYNOPSIS, DESCRIPTION (40+ chars), PARAMETER, EXAMPLE sections before function/class

Applied to files:

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

Applied to files:

  • source/Modules/xRemoteDesktopSessionHost.Common/Public/Get-xRemoteDesktopSessionHostOsVersion.ps1
📚 Learning: 2025-10-26T13:28:23.439Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-10-26T13:28:23.439Z
Learning: Applies to **/*.{ps1,psm1} : Use [OutputType({return type})] for functions with output; use [OutputType()] when no output

Applied to files:

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

Applied to files:

  • source/Modules/xRemoteDesktopSessionHost.Common/Public/Get-xRemoteDesktopSessionHostOsVersion.ps1
📚 Learning: 2025-10-26T13:28:23.439Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-10-26T13:28:23.439Z
Learning: Applies to **/*.{ps1,psm1} : Avoid hardcoded computer names; use cross-platform Get-ComputerName instead of $env:COMPUTERNAME

Applied to files:

  • source/Modules/xRemoteDesktopSessionHost.Common/Public/Get-xRemoteDesktopSessionHostOsVersion.ps1
📚 Learning: 2025-10-26T13:28:23.439Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-10-26T13:28:23.439Z
Learning: Applies to **/*.{ps1,psm1} : OUTPUTS: list each return type with one-line description; repeat keyword per type; must match [OutputType()] and actual returns

Applied to files:

  • source/Modules/xRemoteDesktopSessionHost.Common/Public/Get-xRemoteDesktopSessionHostOsVersion.ps1
📚 Learning: 2025-10-26T13:28:23.439Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-10-26T13:28:23.439Z
Learning: Applies to **/*.{ps1,psm1} : For state-changing functions, use SupportsShouldProcess with immediate ShouldProcess checks before each change, set ConfirmImpact, follow required pattern, avoid Write-Verbose inside the block

Applied to files:

  • source/Modules/xRemoteDesktopSessionHost.Common/Public/Get-xRemoteDesktopSessionHostOsVersion.ps1
📚 Learning: 2025-10-03T15:27:24.417Z
Learnt from: Borgquite
Repo: dsccommunity/UpdateServicesDsc PR: 78
File: source/DSCResources/MSFT_UpdateServicesComputerTargetGroup/MSFT_UpdateServicesComputerTargetGroup.psm1:9-22
Timestamp: 2025-10-03T15:27:24.417Z
Learning: In the UpdateServicesDsc repository, MOF-based DSC resources follow a minimal comment-based help convention that includes only .SYNOPSIS and .PARAMETER sections. The .DESCRIPTION, .INPUTS, and .OUTPUTS sections are intentionally omitted, even though functions have [OutputType()] attributes. This is consistent across all existing DSC resources: MSFT_UpdateServicesServer, MSFT_UpdateServicesCleanup, and MSFT_UpdateServicesApprovalRule.

Applied to files:

  • source/Modules/xRemoteDesktopSessionHost.Common/Public/Get-xRemoteDesktopSessionHostOsVersion.ps1

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

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: 13

🧹 Nitpick comments (6)
source/DSCResources/MSFT_xRDRemoteApp/MSFT_xRDRemoteApp.psm1 (2)

1-5: Add localization import at module top

Import localized strings for messages to comply with MOF resource guidelines.

As per coding guidelines

 Import-Module -Name (Join-Path -Path $modulePath -ChildPath 'DscResource.Common')
 
+# Import localized strings
+$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US'
+

12-12: Ensure RemoteDesktop is imported deterministically

Use -ImportModule for consistency with other resources and to avoid autoload reliance.

As per coding guidelines

-Assert-Module -ModuleName 'RemoteDesktop'
+Assert-Module -ModuleName 'RemoteDesktop' -ImportModule
source/DSCResources/MSFT_xRDSessionCollectionConfiguration/MSFT_xRDSessionCollectionConfiguration.psm1 (2)

1-5: Add localization import at module top

Load localized strings so verbose/error messages are not hardcoded.

As per coding guidelines

 Import-Module -Name (Join-Path -Path $modulePath -ChildPath 'DscResource.Common')
 
+# Import localized strings
+$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US'
+

12-12: Align Assert-Module usage with other resources

Add -ImportModule to actually import RemoteDesktop and avoid relying on autoloading.

As per coding guidelines

-Assert-Module -ModuleName 'RemoteDesktop'
+Assert-Module -ModuleName 'RemoteDesktop' -ImportModule
source/Modules/xRemoteDesktopSessionHost.Common/xRemoteDesktopSessionHost.Common.psd1 (1)

72-72: Empty FunctionsToExport may block public function exports

With FunctionsToExport = @(), nothing is exported unless the psm1 calls Export-ModuleMember. Please confirm the psm1 explicitly exports Get-xRemoteDesktopSessionHostOsVersion and Test-xRemoteDesktopSessionHostOsRequirement, or list them here.

build.yaml (1)

76-92: Pester output encodings

Consider using utf8 for OutputEncoding/TestResult to align with UTF‑8 file encoding policy and avoid non‑ASCII truncation in logs.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 35aa561 and 3427bee.

📒 Files selected for processing (42)
  • .vscode/settings.json (1 hunks)
  • CHANGELOG.md (1 hunks)
  • RequiredModules.psd1 (2 hunks)
  • azure-pipelines.yml (1 hunks)
  • build.yaml (4 hunks)
  • source/DSCResources/MSFT_xRDCertificateConfiguration/MSFT_xRDCertificateConfiguration.psm1 (3 hunks)
  • source/DSCResources/MSFT_xRDConnectionBrokerHAMode/MSFT_xRDConnectionBrokerHAMode.psm1 (3 hunks)
  • source/DSCResources/MSFT_xRDGatewayConfiguration/MSFT_xRDGatewayConfiguration.psm1 (2 hunks)
  • source/DSCResources/MSFT_xRDLicenseConfiguration/MSFT_xRDLicenseConfiguration.psm1 (1 hunks)
  • source/DSCResources/MSFT_xRDRemoteApp/MSFT_xRDRemoteApp.psm1 (1 hunks)
  • source/DSCResources/MSFT_xRDServer/MSFT_xRDServer.psm1 (1 hunks)
  • source/DSCResources/MSFT_xRDSessionCollection/MSFT_xRDSessionCollection.psm1 (1 hunks)
  • source/DSCResources/MSFT_xRDSessionCollectionConfiguration/MSFT_xRDSessionCollectionConfiguration.psm1 (1 hunks)
  • source/DSCResources/MSFT_xRDSessionDeployment/MSFT_xRDSessionDeployment.psm1 (1 hunks)
  • source/Modules/en-US/xRemoteDesktopSessionHostCommon.strings.psd1 (0 hunks)
  • source/Modules/xRemoteDesktopSessionHost.Common/Public/Get-xRemoteDesktopSessionHostOsVersion.ps1 (1 hunks)
  • source/Modules/xRemoteDesktopSessionHost.Common/Public/Test-xRemoteDesktopSessionHostOsRequirement.ps1 (1 hunks)
  • source/Modules/xRemoteDesktopSessionHost.Common/en-US/xRemoteDesktopSessionHost.Common.strings.psd1 (1 hunks)
  • source/Modules/xRemoteDesktopSessionHost.Common/prefix.ps1 (1 hunks)
  • source/Modules/xRemoteDesktopSessionHost.Common/xRemoteDesktopSessionHost.Common.psd1 (3 hunks)
  • source/Modules/xRemoteDesktopSessionHostCommon.psm1 (0 hunks)
  • source/en-US/xRemoteDesktopSessionHost.strings.psd1 (1 hunks)
  • tests/Unit/MSFT_xRDCertificateConfiguration.Tests.ps1 (1 hunks)
  • tests/Unit/MSFT_xRDCertificateConfiguration.tests.ps1 (0 hunks)
  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1 (1 hunks)
  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.tests.ps1 (0 hunks)
  • tests/Unit/MSFT_xRDGatewayConfiguration.Tests.ps1 (1 hunks)
  • tests/Unit/MSFT_xRDGatewayConfiguration.tests.ps1 (0 hunks)
  • tests/Unit/MSFT_xRDLicenseConfiguration.Tests.ps1 (1 hunks)
  • tests/Unit/MSFT_xRDLicenseConfiguration.tests.ps1 (0 hunks)
  • tests/Unit/MSFT_xRDRemoteApp.Tests.ps1 (1 hunks)
  • tests/Unit/MSFT_xRDRemoteApp.tests.ps1 (0 hunks)
  • tests/Unit/MSFT_xRDServer.Tests.ps1 (1 hunks)
  • tests/Unit/MSFT_xRDServer.tests.ps1 (0 hunks)
  • tests/Unit/MSFT_xRDSessionCollection.Tests.ps1 (1 hunks)
  • tests/Unit/MSFT_xRDSessionCollection.tests.ps1 (0 hunks)
  • tests/Unit/MSFT_xRDSessionCollectionConfiguration.Tests.ps1 (1 hunks)
  • tests/Unit/MSFT_xRDSessionCollectionConfiguration.tests.ps1 (0 hunks)
  • tests/Unit/MSFT_xRDSessionDeployment.Tests.ps1 (1 hunks)
  • tests/Unit/MSFT_xRDSessionDeployment.tests.ps1 (0 hunks)
  • tests/Unit/xRemoteDesktopSessionHost.Common/Public/Test-xRemoteDesktopSessionHostOsRequirement.Tests.ps1 (1 hunks)
  • tests/Unit/xRemoteDesktopSessionHost.tests.ps1 (0 hunks)
💤 Files with no reviewable changes (12)
  • source/Modules/xRemoteDesktopSessionHostCommon.psm1
  • tests/Unit/MSFT_xRDRemoteApp.tests.ps1
  • tests/Unit/MSFT_xRDServer.tests.ps1
  • tests/Unit/MSFT_xRDLicenseConfiguration.tests.ps1
  • tests/Unit/MSFT_xRDSessionDeployment.tests.ps1
  • tests/Unit/xRemoteDesktopSessionHost.tests.ps1
  • tests/Unit/MSFT_xRDCertificateConfiguration.tests.ps1
  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.tests.ps1
  • tests/Unit/MSFT_xRDSessionCollectionConfiguration.tests.ps1
  • tests/Unit/MSFT_xRDSessionCollection.tests.ps1
  • tests/Unit/MSFT_xRDGatewayConfiguration.tests.ps1
  • source/Modules/en-US/xRemoteDesktopSessionHostCommon.strings.psd1
🧰 Additional context used
📓 Path-based instructions (8)
**

⚙️ 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
  • 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/Modules/xRemoteDesktopSessionHost.Common/xRemoteDesktopSessionHost.Common.psd1
  • tests/Unit/MSFT_xRDSessionCollectionConfiguration.Tests.ps1
  • source/DSCResources/MSFT_xRDLicenseConfiguration/MSFT_xRDLicenseConfiguration.psm1
  • source/DSCResources/MSFT_xRDServer/MSFT_xRDServer.psm1
  • tests/Unit/xRemoteDesktopSessionHost.Common/Public/Test-xRemoteDesktopSessionHostOsRequirement.Tests.ps1
  • build.yaml
  • tests/Unit/MSFT_xRDRemoteApp.Tests.ps1
  • azure-pipelines.yml
  • CHANGELOG.md
  • source/DSCResources/MSFT_xRDSessionCollection/MSFT_xRDSessionCollection.psm1
  • source/Modules/xRemoteDesktopSessionHost.Common/prefix.ps1
  • source/DSCResources/MSFT_xRDRemoteApp/MSFT_xRDRemoteApp.psm1
  • source/DSCResources/MSFT_xRDCertificateConfiguration/MSFT_xRDCertificateConfiguration.psm1
  • tests/Unit/MSFT_xRDServer.Tests.ps1
  • tests/Unit/MSFT_xRDSessionCollection.Tests.ps1
  • tests/Unit/MSFT_xRDGatewayConfiguration.Tests.ps1
  • source/Modules/xRemoteDesktopSessionHost.Common/Public/Get-xRemoteDesktopSessionHostOsVersion.ps1
  • source/Modules/xRemoteDesktopSessionHost.Common/en-US/xRemoteDesktopSessionHost.Common.strings.psd1
  • source/en-US/xRemoteDesktopSessionHost.strings.psd1
  • tests/Unit/MSFT_xRDLicenseConfiguration.Tests.ps1
  • source/DSCResources/MSFT_xRDSessionCollectionConfiguration/MSFT_xRDSessionCollectionConfiguration.psm1
  • tests/Unit/MSFT_xRDSessionDeployment.Tests.ps1
  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
  • source/DSCResources/MSFT_xRDSessionDeployment/MSFT_xRDSessionDeployment.psm1
  • tests/Unit/MSFT_xRDCertificateConfiguration.Tests.ps1
  • source/Modules/xRemoteDesktopSessionHost.Common/Public/Test-xRemoteDesktopSessionHostOsRequirement.ps1
  • source/DSCResources/MSFT_xRDGatewayConfiguration/MSFT_xRDGatewayConfiguration.psm1
  • source/DSCResources/MSFT_xRDConnectionBrokerHAMode/MSFT_xRDConnectionBrokerHAMode.psm1
  • RequiredModules.psd1
{**/*.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 (one per line) with a 1‑line description...

Files:

  • source/Modules/xRemoteDesktopSessionHost.Common/xRemoteDesktopSessionHost.Common.psd1
  • tests/Unit/MSFT_xRDSessionCollectionConfiguration.Tests.ps1
  • source/DSCResources/MSFT_xRDLicenseConfiguration/MSFT_xRDLicenseConfiguration.psm1
  • source/DSCResources/MSFT_xRDServer/MSFT_xRDServer.psm1
  • tests/Unit/xRemoteDesktopSessionHost.Common/Public/Test-xRemoteDesktopSessionHostOsRequirement.Tests.ps1
  • tests/Unit/MSFT_xRDRemoteApp.Tests.ps1
  • source/DSCResources/MSFT_xRDSessionCollection/MSFT_xRDSessionCollection.psm1
  • source/Modules/xRemoteDesktopSessionHost.Common/prefix.ps1
  • source/DSCResources/MSFT_xRDRemoteApp/MSFT_xRDRemoteApp.psm1
  • source/DSCResources/MSFT_xRDCertificateConfiguration/MSFT_xRDCertificateConfiguration.psm1
  • tests/Unit/MSFT_xRDServer.Tests.ps1
  • tests/Unit/MSFT_xRDSessionCollection.Tests.ps1
  • tests/Unit/MSFT_xRDGatewayConfiguration.Tests.ps1
  • source/Modules/xRemoteDesktopSessionHost.Common/Public/Get-xRemoteDesktopSessionHostOsVersion.ps1
  • source/Modules/xRemoteDesktopSessionHost.Common/en-US/xRemoteDesktopSessionHost.Common.strings.psd1
  • source/en-US/xRemoteDesktopSessionHost.strings.psd1
  • tests/Unit/MSFT_xRDLicenseConfiguration.Tests.ps1
  • source/DSCResources/MSFT_xRDSessionCollectionConfiguration/MSFT_xRDSessionCollectionConfiguration.psm1
  • tests/Unit/MSFT_xRDSessionDeployment.Tests.ps1
  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
  • source/DSCResources/MSFT_xRDSessionDeployment/MSFT_xRDSessionDeployment.psm1
  • tests/Unit/MSFT_xRDCertificateConfiguration.Tests.ps1
  • source/Modules/xRemoteDesktopSessionHost.Common/Public/Test-xRemoteDesktopSessionHostOsRequirement.ps1
  • source/DSCResources/MSFT_xRDGatewayConfiguration/MSFT_xRDGatewayConfiguration.psm1
  • source/DSCResources/MSFT_xRDConnectionBrokerHAMode/MSFT_xRDConnectionBrokerHAMode.psm1
  • RequiredModules.psd1
tests/[Uu]nit/**/*.[Tt]ests.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 -Force -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:ModuleNam...

Files:

  • tests/Unit/MSFT_xRDSessionCollectionConfiguration.Tests.ps1
  • tests/Unit/xRemoteDesktopSessionHost.Common/Public/Test-xRemoteDesktopSessionHostOsRequirement.Tests.ps1
  • tests/Unit/MSFT_xRDRemoteApp.Tests.ps1
  • tests/Unit/MSFT_xRDServer.Tests.ps1
  • tests/Unit/MSFT_xRDSessionCollection.Tests.ps1
  • tests/Unit/MSFT_xRDGatewayConfiguration.Tests.ps1
  • tests/Unit/MSFT_xRDLicenseConfiguration.Tests.ps1
  • tests/Unit/MSFT_xRDSessionDeployment.Tests.ps1
  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
  • tests/Unit/MSFT_xRDCertificateConfiguration.Tests.ps1
**/*.[Tt]ests.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)
  • 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

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, InModuleScope:ModuleName
  • Omit -ModuleName parameter on Pester commands
  • Never use Mock inside `InModuleSc...

Files:

  • tests/Unit/MSFT_xRDSessionCollectionConfiguration.Tests.ps1
  • tests/Unit/xRemoteDesktopSessionHost.Common/Public/Test-xRemoteDesktopSessionHostOsRequirement.Tests.ps1
  • tests/Unit/MSFT_xRDRemoteApp.Tests.ps1
  • tests/Unit/MSFT_xRDServer.Tests.ps1
  • tests/Unit/MSFT_xRDSessionCollection.Tests.ps1
  • tests/Unit/MSFT_xRDGatewayConfiguration.Tests.ps1
  • tests/Unit/MSFT_xRDLicenseConfiguration.Tests.ps1
  • tests/Unit/MSFT_xRDSessionDeployment.Tests.ps1
  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
  • tests/Unit/MSFT_xRDCertificateConfiguration.Tests.ps1
source/DSCResources/**/*.psm1

⚙️ CodeRabbit configuration file

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

Required Functions

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

Function Return Types

  • Get-TargetResource: Must return hashtable with all resource properties
  • Test-TargetResource: Must return boolean ($true/$false)
  • Set-TargetResource: Must not return anything (void)

Parameter Guidelines

  • Get-TargetResource: Only include parameters needed to retrieve actual current state values
  • Get-TargetResource: Remove non-mandatory parameters that are never used
  • Set-TargetResource and Test-TargetResource: Must have identical parameters
  • Set-TargetResource and Test-TargetResource: Unused mandatory parameters: Add "Not used in <function_name>" to help comment

Required Elements

  • Each function must include Write-Verbose at least once
    • Get-TargetResource: Use verbose message starting with "Getting the current state of..."
    • Set-TargetResource: Use verbose message starting with "Setting the desired state of..."
    • Test-TargetResource: Use verbose message starting with "Determining the current state of..."
  • Use localized strings for all messages (Write-Verbose, Write-Error, etc.)
  • Import localized strings using Get-LocalizedData at module top

Error Handling

Files:

  • source/DSCResources/MSFT_xRDLicenseConfiguration/MSFT_xRDLicenseConfiguration.psm1
  • source/DSCResources/MSFT_xRDServer/MSFT_xRDServer.psm1
  • source/DSCResources/MSFT_xRDSessionCollection/MSFT_xRDSessionCollection.psm1
  • source/DSCResources/MSFT_xRDRemoteApp/MSFT_xRDRemoteApp.psm1
  • source/DSCResources/MSFT_xRDCertificateConfiguration/MSFT_xRDCertificateConfiguration.psm1
  • source/DSCResources/MSFT_xRDSessionCollectionConfiguration/MSFT_xRDSessionCollectionConfiguration.psm1
  • source/DSCResources/MSFT_xRDSessionDeployment/MSFT_xRDSessionDeployment.psm1
  • source/DSCResources/MSFT_xRDGatewayConfiguration/MSFT_xRDGatewayConfiguration.psm1
  • source/DSCResources/MSFT_xRDConnectionBrokerHAMode/MSFT_xRDConnectionBrokerHAMode.psm1
**/*.md

⚙️ CodeRabbit configuration file

**/*.md: # Markdown Style Guidelines

  • Wrap lines at word boundaries when over 80 characters (except tables/code blocks)
  • Use 2 spaces for indentation
  • Use '1.' for all items in ordered lists (1/1/1 numbering style)
  • Disable MD013 rule by adding a comment for tables/code blocks exceeding 80 characters
  • Empty lines required before/after code blocks and headings (except before line 1)
  • Escape backslashes in file paths only (not in code blocks)
  • Code blocks must specify language identifiers

Text Formatting

  • Parameters: bold
  • Values/literals: inline code
  • Resource/module/product names: italic
  • Commands/files/paths: inline code

Files:

  • CHANGELOG.md
CHANGELOG.md

⚙️ CodeRabbit configuration file

CHANGELOG.md: # Changelog Guidelines

  • Always update the Unreleased section in CHANGELOG.md
  • Use Keep a Changelog format
  • Describe notable changes briefly, ≤2 items per change type
  • Reference issues using format issue #<issue_number>
  • No empty lines between list items in same section
  • Skip adding entry if same change already exists in Unreleased section
  • No duplicate sections or items in Unreleased section

Files:

  • CHANGELOG.md
source/**/*.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/Modules/xRemoteDesktopSessionHost.Common/prefix.ps1
  • source/Modules/xRemoteDesktopSessionHost.Common/Public/Get-xRemoteDesktopSessionHostOsVersion.ps1
  • source/Modules/xRemoteDesktopSessionHost.Common/Public/Test-xRemoteDesktopSessionHostOsRequirement.ps1
🧠 Learnings (41)
📓 Common learnings
Learnt from: dan-hughes
PR: dsccommunity/UpdateServicesDsc#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: dan-hughes
PR: dsccommunity/ActiveDirectoryDsc#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.
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-12T13:21:31.054Z
Learning: Applies to **/*.[Tt]ests.ps1 : Use Pester v5 syntax only
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-unit-tests.instructions.md:0-0
Timestamp: 2025-09-16T16:34:44.689Z
Learning: Applies to tests/[Uu]nit/**/*.[Tt]ests.ps1 : Include the exact Pester setup block before Describe: SuppressMessage attribute with param (); BeforeDiscovery to ensure DscResource.Test is available (fallback to build.ps1 -Tasks 'noop') and Import-Module; BeforeAll to set $script:moduleName, import the module, and set PSDefaultParameterValues for InModuleScope/Mock/Should; AfterAll to remove those defaults and unload the tested module
📚 Learning: 2025-09-16T16:34:44.689Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-unit-tests.instructions.md:0-0
Timestamp: 2025-09-16T16:34:44.689Z
Learning: Applies to tests/[Uu]nit/**/*.[Tt]ests.ps1 : Include the exact Pester setup block before Describe: SuppressMessage attribute with param (); BeforeDiscovery to ensure DscResource.Test is available (fallback to build.ps1 -Tasks 'noop') and Import-Module; BeforeAll to set $script:moduleName, import the module, and set PSDefaultParameterValues for InModuleScope/Mock/Should; AfterAll to remove those defaults and unload the tested module

Applied to files:

  • tests/Unit/MSFT_xRDSessionCollectionConfiguration.Tests.ps1
  • tests/Unit/xRemoteDesktopSessionHost.Common/Public/Test-xRemoteDesktopSessionHostOsRequirement.Tests.ps1
  • build.yaml
  • tests/Unit/MSFT_xRDRemoteApp.Tests.ps1
  • tests/Unit/MSFT_xRDServer.Tests.ps1
  • tests/Unit/MSFT_xRDSessionCollection.Tests.ps1
  • tests/Unit/MSFT_xRDGatewayConfiguration.Tests.ps1
  • tests/Unit/MSFT_xRDLicenseConfiguration.Tests.ps1
  • tests/Unit/MSFT_xRDSessionDeployment.Tests.ps1
  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
  • tests/Unit/MSFT_xRDCertificateConfiguration.Tests.ps1
📚 Learning: 2025-09-16T16:35:31.909Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines.instructions.md:0-0
Timestamp: 2025-09-16T16:35:31.909Z
Learning: Applies to tests/Unit/{Classes,Public,Private}/*.Tests.ps1 : Add unit tests for all commands, functions, and resources

Applied to files:

  • tests/Unit/MSFT_xRDSessionCollectionConfiguration.Tests.ps1
  • tests/Unit/MSFT_xRDRemoteApp.Tests.ps1
  • tests/Unit/MSFT_xRDServer.Tests.ps1
  • tests/Unit/MSFT_xRDSessionCollection.Tests.ps1
  • tests/Unit/MSFT_xRDGatewayConfiguration.Tests.ps1
  • tests/Unit/MSFT_xRDSessionDeployment.Tests.ps1
  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
  • tests/Unit/MSFT_xRDCertificateConfiguration.Tests.ps1
📚 Learning: 2025-09-12T13:20:57.155Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-09-12T13:20:57.155Z
Learning: Applies to source/DSCResources/**/*.psm1 : Test-TargetResource must return a boolean ($true/$false)

Applied to files:

  • tests/Unit/MSFT_xRDSessionCollectionConfiguration.Tests.ps1
  • tests/Unit/MSFT_xRDRemoteApp.Tests.ps1
  • tests/Unit/MSFT_xRDServer.Tests.ps1
  • tests/Unit/MSFT_xRDSessionCollection.Tests.ps1
  • tests/Unit/MSFT_xRDSessionDeployment.Tests.ps1
  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
  • tests/Unit/MSFT_xRDCertificateConfiguration.Tests.ps1
📚 Learning: 2025-09-12T13:20:57.155Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-09-12T13:20:57.155Z
Learning: Applies to source/DSCResources/**/*.psm1 : Set-TargetResource and Test-TargetResource must have identical parameters

Applied to files:

  • tests/Unit/MSFT_xRDSessionCollectionConfiguration.Tests.ps1
  • source/DSCResources/MSFT_xRDLicenseConfiguration/MSFT_xRDLicenseConfiguration.psm1
  • tests/Unit/MSFT_xRDRemoteApp.Tests.ps1
  • source/DSCResources/MSFT_xRDSessionCollection/MSFT_xRDSessionCollection.psm1
  • source/DSCResources/MSFT_xRDRemoteApp/MSFT_xRDRemoteApp.psm1
  • tests/Unit/MSFT_xRDSessionCollection.Tests.ps1
  • source/DSCResources/MSFT_xRDSessionCollectionConfiguration/MSFT_xRDSessionCollectionConfiguration.psm1
  • tests/Unit/MSFT_xRDSessionDeployment.Tests.ps1
  • source/DSCResources/MSFT_xRDSessionDeployment/MSFT_xRDSessionDeployment.psm1
  • tests/Unit/MSFT_xRDCertificateConfiguration.Tests.ps1
📚 Learning: 2025-10-10T14:01:42.703Z
Learnt from: dan-hughes
PR: dsccommunity/UpdateServicesDsc#86
File: tests/Unit/MSFT_UpdateServicesServer.Tests.ps1:6-45
Timestamp: 2025-10-10T14:01:42.703Z
Learning: For script-based (MOF) DSC resources in UpdateServicesDsc, unit tests should use Initialize-TestEnvironment with variables $script:dscModuleName and $script:dscResourceName, and set -ResourceType 'Mof'. This differs from class-based resource tests which use the simpler $script:moduleName template without Initialize-TestEnvironment.

Applied to files:

  • tests/Unit/MSFT_xRDSessionCollectionConfiguration.Tests.ps1
  • tests/Unit/MSFT_xRDRemoteApp.Tests.ps1
  • tests/Unit/MSFT_xRDServer.Tests.ps1
  • tests/Unit/MSFT_xRDLicenseConfiguration.Tests.ps1
  • tests/Unit/MSFT_xRDSessionDeployment.Tests.ps1
  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
  • tests/Unit/MSFT_xRDCertificateConfiguration.Tests.ps1
📚 Learning: 2025-09-12T13:20:57.155Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-09-12T13:20:57.155Z
Learning: Applies to source/DSCResources/**/*.psm1 : Set-TargetResource must not return anything (void)

Applied to files:

  • tests/Unit/MSFT_xRDSessionCollectionConfiguration.Tests.ps1
  • tests/Unit/MSFT_xRDRemoteApp.Tests.ps1
  • source/DSCResources/MSFT_xRDRemoteApp/MSFT_xRDRemoteApp.psm1
  • tests/Unit/MSFT_xRDSessionCollection.Tests.ps1
  • source/DSCResources/MSFT_xRDSessionCollectionConfiguration/MSFT_xRDSessionCollectionConfiguration.psm1
  • tests/Unit/MSFT_xRDSessionDeployment.Tests.ps1
  • tests/Unit/MSFT_xRDCertificateConfiguration.Tests.ps1
📚 Learning: 2025-09-12T13:20:57.155Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-09-12T13:20:57.155Z
Learning: Applies to source/DSCResources/**/*.psm1 : Every MOF DSC resource module must define the functions: Get-TargetResource, Set-TargetResource, and Test-TargetResource

Applied to files:

  • source/DSCResources/MSFT_xRDLicenseConfiguration/MSFT_xRDLicenseConfiguration.psm1
  • tests/Unit/MSFT_xRDRemoteApp.Tests.ps1
  • source/DSCResources/MSFT_xRDSessionCollection/MSFT_xRDSessionCollection.psm1
  • source/DSCResources/MSFT_xRDRemoteApp/MSFT_xRDRemoteApp.psm1
  • source/DSCResources/MSFT_xRDCertificateConfiguration/MSFT_xRDCertificateConfiguration.psm1
  • tests/Unit/MSFT_xRDServer.Tests.ps1
  • source/DSCResources/MSFT_xRDSessionCollectionConfiguration/MSFT_xRDSessionCollectionConfiguration.psm1
  • source/DSCResources/MSFT_xRDSessionDeployment/MSFT_xRDSessionDeployment.psm1
  • tests/Unit/MSFT_xRDCertificateConfiguration.Tests.ps1
📚 Learning: 2025-09-12T13:20:57.155Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-09-12T13:20:57.155Z
Learning: Applies to source/DSCResources/**/*.psm1 : Export resource functions using the *-TargetResource naming pattern

Applied to files:

  • source/DSCResources/MSFT_xRDLicenseConfiguration/MSFT_xRDLicenseConfiguration.psm1
  • source/DSCResources/MSFT_xRDSessionCollection/MSFT_xRDSessionCollection.psm1
  • source/DSCResources/MSFT_xRDRemoteApp/MSFT_xRDRemoteApp.psm1
  • source/DSCResources/MSFT_xRDCertificateConfiguration/MSFT_xRDCertificateConfiguration.psm1
  • source/DSCResources/MSFT_xRDSessionCollectionConfiguration/MSFT_xRDSessionCollectionConfiguration.psm1
  • source/DSCResources/MSFT_xRDSessionDeployment/MSFT_xRDSessionDeployment.psm1
📚 Learning: 2025-09-12T13:20:57.155Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-09-12T13:20:57.155Z
Learning: Applies to source/DSCResources/**/*.psm1 : Get-TargetResource must return a hashtable containing all resource properties

Applied to files:

  • source/DSCResources/MSFT_xRDLicenseConfiguration/MSFT_xRDLicenseConfiguration.psm1
  • source/DSCResources/MSFT_xRDSessionCollection/MSFT_xRDSessionCollection.psm1
  • source/DSCResources/MSFT_xRDRemoteApp/MSFT_xRDRemoteApp.psm1
  • source/DSCResources/MSFT_xRDCertificateConfiguration/MSFT_xRDCertificateConfiguration.psm1
  • source/DSCResources/MSFT_xRDSessionCollectionConfiguration/MSFT_xRDSessionCollectionConfiguration.psm1
  • source/DSCResources/MSFT_xRDSessionDeployment/MSFT_xRDSessionDeployment.psm1
📚 Learning: 2025-09-12T13:20:57.155Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-09-12T13:20:57.155Z
Learning: Applies to source/DSCResources/**/*.psm1 : Get-TargetResource parameters: include only those needed to retrieve actual current state values

Applied to files:

  • source/DSCResources/MSFT_xRDLicenseConfiguration/MSFT_xRDLicenseConfiguration.psm1
  • source/DSCResources/MSFT_xRDSessionCollection/MSFT_xRDSessionCollection.psm1
  • source/DSCResources/MSFT_xRDRemoteApp/MSFT_xRDRemoteApp.psm1
  • source/DSCResources/MSFT_xRDCertificateConfiguration/MSFT_xRDCertificateConfiguration.psm1
  • source/DSCResources/MSFT_xRDSessionCollectionConfiguration/MSFT_xRDSessionCollectionConfiguration.psm1
  • source/DSCResources/MSFT_xRDSessionDeployment/MSFT_xRDSessionDeployment.psm1
📚 Learning: 2025-09-12T13:20:57.155Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-09-12T13:20:57.155Z
Learning: Applies to source/DSCResources/**/*.psm1 : Get-TargetResource: remove non-mandatory parameters that are never used

Applied to files:

  • source/DSCResources/MSFT_xRDLicenseConfiguration/MSFT_xRDLicenseConfiguration.psm1
  • source/DSCResources/MSFT_xRDSessionCollection/MSFT_xRDSessionCollection.psm1
  • source/DSCResources/MSFT_xRDRemoteApp/MSFT_xRDRemoteApp.psm1
  • source/DSCResources/MSFT_xRDCertificateConfiguration/MSFT_xRDCertificateConfiguration.psm1
  • source/DSCResources/MSFT_xRDSessionCollectionConfiguration/MSFT_xRDSessionCollectionConfiguration.psm1
  • source/DSCResources/MSFT_xRDSessionDeployment/MSFT_xRDSessionDeployment.psm1
📚 Learning: 2025-10-11T08:18:26.062Z
Learnt from: johlju
PR: dsccommunity/SqlServerDsc#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/Unit/xRemoteDesktopSessionHost.Common/Public/Test-xRemoteDesktopSessionHostOsRequirement.Tests.ps1
📚 Learning: 2025-08-10T15:11:52.897Z
Learnt from: dan-hughes
PR: dsccommunity/ActiveDirectoryDsc#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/Unit/xRemoteDesktopSessionHost.Common/Public/Test-xRemoteDesktopSessionHostOsRequirement.Tests.ps1
  • build.yaml
📚 Learning: 2025-09-23T10:20:59.832Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-09-23T10:20:59.832Z
Learning: Run QA tests via: Invoke-PesterJob -Path 'tests/QA' -SkipCodeCoverage

Applied to files:

  • build.yaml
📚 Learning: 2025-09-23T10:20:59.832Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-09-23T10:20:59.832Z
Learning: Run tests with Invoke-PesterJob (wildcards allowed) with coverage using -EnableSourceLineMapping and -FilterCodeCoverageResult

Applied to files:

  • build.yaml
📚 Learning: 2025-09-23T10:20:59.832Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-09-23T10:20:59.832Z
Learning: Run tests with Invoke-PesterJob (wildcards allowed) without coverage using -SkipCodeCoverage

Applied to files:

  • build.yaml
📚 Learning: 2025-10-12T11:23:30.123Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-10-12T11:23:30.123Z
Learning: Applies to tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1 : Include the required Pester setup block (SuppressMessage param, BeforeDiscovery loading DscResource.Test, and BeforeAll importing the module)

Applied to files:

  • build.yaml
📚 Learning: 2025-09-12T13:21:31.054Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-12T13:21:31.054Z
Learning: Applies to **/*.[Tt]ests.ps1 : Use Pester v5 syntax only

Applied to files:

  • build.yaml
📚 Learning: 2025-09-12T13:21:31.054Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-12T13:21:31.054Z
Learning: Applies to **/*.[Tt]ests.ps1 : Omit the -ModuleName parameter on Pester commands

Applied to files:

  • build.yaml
📚 Learning: 2025-08-28T15:44:12.628Z
Learnt from: johlju
PR: dsccommunity/SqlServerDsc#2150
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:35-35
Timestamp: 2025-08-28T15:44:12.628Z
Learning: The SqlServerDsc repository uses RequiredModules.psd1 to specify Pester with Version = 'latest' and AllowPrerelease = $true, ensuring the latest Pester version (well beyond 5.4) is available, which supports Should -Invoke syntax and other modern Pester features.

Applied to files:

  • build.yaml
  • RequiredModules.psd1
📚 Learning: 2025-10-11T08:35:56.141Z
Learnt from: johlju
PR: dsccommunity/SqlServerDsc#2300
File: tests/Unit/DSC_SqlAGDatabase.Tests.ps1:22-22
Timestamp: 2025-10-11T08:35:56.141Z
Learning: In DSC Community projects, when writing error messages for missing DscResource.Test module dependency in unit test files (tests/[Uu]nit/**/*.[Tt]ests.ps1), the policy is: new code should instruct users to run ".\build.ps1 -Tasks noop" for quick test environment setup; existing code using ".\build.ps1 -Tasks build" is acceptable but slower since it also builds the project. The `noop` task is preferred as it assumes the module is already built before running tests, especially when tests run in a separate process.

Applied to files:

  • build.yaml
📚 Learning: 2025-09-12T13:21:31.054Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-12T13:21:31.054Z
Learning: Applies to **/*.[Tt]ests.ps1 : Use $PSDefaultParameterValues only for Pester commands (Describe, Context, It, Mock, Should, InModuleScope)

Applied to files:

  • build.yaml
📚 Learning: 2025-09-12T13:20:57.155Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-09-12T13:20:57.155Z
Learning: Applies to source/DSCResources/**/*.psm1 : Import localized strings at the top of the module using Get-LocalizedData

Applied to files:

  • source/Modules/xRemoteDesktopSessionHost.Common/prefix.ps1
  • source/DSCResources/MSFT_xRDCertificateConfiguration/MSFT_xRDCertificateConfiguration.psm1
  • source/Modules/xRemoteDesktopSessionHost.Common/en-US/xRemoteDesktopSessionHost.Common.strings.psd1
  • source/en-US/xRemoteDesktopSessionHost.strings.psd1
📚 Learning: 2025-10-04T21:33:23.022Z
Learnt from: dan-hughes
PR: dsccommunity/UpdateServicesDsc#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/Modules/xRemoteDesktopSessionHost.Common/prefix.ps1
  • source/Modules/xRemoteDesktopSessionHost.Common/en-US/xRemoteDesktopSessionHost.Common.strings.psd1
  • source/en-US/xRemoteDesktopSessionHost.strings.psd1
📚 Learning: 2025-09-12T13:20:14.850Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-class-resource.instructions.md:0-0
Timestamp: 2025-09-12T13:20:14.850Z
Learning: Applies to source/[cC]lasses/**/*.ps1 : Use $this.localizedData provided by ResourceBase (do not manually populate)

Applied to files:

  • source/Modules/xRemoteDesktopSessionHost.Common/prefix.ps1
📚 Learning: 2025-09-12T13:20:57.155Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-09-12T13:20:57.155Z
Learning: Applies to source/DSCResources/**/[a-z][a-z]-[A-Z][A-Z]/DSC_*.strings.psd1 : Additional localization folders must be named using Get-UICulture names (e.g., fr-FR) and contain DSC_<ResourceName>.strings.psd1

Applied to files:

  • source/Modules/xRemoteDesktopSessionHost.Common/prefix.ps1
  • source/en-US/xRemoteDesktopSessionHost.strings.psd1
📚 Learning: 2025-09-12T13:20:57.155Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-09-12T13:20:57.155Z
Learning: Applies to source/DSCResources/**/*.psm1 : Use localized strings for all messages (e.g., Write-Verbose, Write-Error)

Applied to files:

  • source/Modules/xRemoteDesktopSessionHost.Common/prefix.ps1
  • source/Modules/xRemoteDesktopSessionHost.Common/en-US/xRemoteDesktopSessionHost.Common.strings.psd1
  • source/en-US/xRemoteDesktopSessionHost.strings.psd1
📚 Learning: 2025-09-12T13:20:57.155Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-09-12T13:20:57.155Z
Learning: Applies to source/DSCResources/**/en-US/DSC_*.strings.psd1 : Each resource directory must contain an en-US localization folder with a strings file named DSC_<ResourceName>.strings.psd1

Applied to files:

  • source/Modules/xRemoteDesktopSessionHost.Common/prefix.ps1
  • source/Modules/xRemoteDesktopSessionHost.Common/en-US/xRemoteDesktopSessionHost.Common.strings.psd1
  • source/en-US/xRemoteDesktopSessionHost.strings.psd1
📚 Learning: 2025-08-29T17:22:23.268Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-localization.instructions.md:0-0
Timestamp: 2025-08-29T17:22:23.268Z
Learning: Applies to source/**/*.ps1 : Assume and use $script:localizedData for accessing localized strings

Applied to files:

  • source/Modules/xRemoteDesktopSessionHost.Common/prefix.ps1
📚 Learning: 2025-09-16T16:34:44.689Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-unit-tests.instructions.md:0-0
Timestamp: 2025-09-16T16:34:44.689Z
Learning: Applies to tests/[Uu]nit/**/*.[Tt]ests.ps1 : In unit tests, access localized strings using InModuleScope -ScriptBlock { $script:localizedData.Key }

Applied to files:

  • source/Modules/xRemoteDesktopSessionHost.Common/prefix.ps1
📚 Learning: 2025-08-29T17:22:23.268Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-localization.instructions.md:0-0
Timestamp: 2025-08-29T17:22:23.268Z
Learning: Applies to source/**/*.ps1 : Use localized string keys instead of hardcoded strings in script output/messages

Applied to files:

  • source/Modules/xRemoteDesktopSessionHost.Common/prefix.ps1
  • source/Modules/xRemoteDesktopSessionHost.Common/en-US/xRemoteDesktopSessionHost.Common.strings.psd1
📚 Learning: 2025-08-17T10:48:15.384Z
Learnt from: johlju
PR: dsccommunity/SqlServerDsc#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/Modules/xRemoteDesktopSessionHost.Common/prefix.ps1
📚 Learning: 2025-08-29T17:22:23.268Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-localization.instructions.md:0-0
Timestamp: 2025-08-29T17:22:23.268Z
Learning: Applies to source/en-US/*.strings.psd1 : Store command/function localization in source/en-US/{MyModuleName}.strings.psd1

Applied to files:

  • source/Modules/xRemoteDesktopSessionHost.Common/en-US/xRemoteDesktopSessionHost.Common.strings.psd1
  • source/en-US/xRemoteDesktopSessionHost.strings.psd1
📚 Learning: 2025-08-29T17:22:23.268Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-localization.instructions.md:0-0
Timestamp: 2025-08-29T17:22:23.268Z
Learning: Applies to source/en-US/*.strings.psd1 : Store class localization in source/en-US/{ResourceClassName}.strings.psd1

Applied to files:

  • source/Modules/xRemoteDesktopSessionHost.Common/en-US/xRemoteDesktopSessionHost.Common.strings.psd1
  • source/en-US/xRemoteDesktopSessionHost.strings.psd1
📚 Learning: 2025-08-29T17:22:23.268Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-localization.instructions.md:0-0
Timestamp: 2025-08-29T17:22:23.268Z
Learning: Applies to source/en-US/*.strings.psd1 : Define strings using ConvertFrom-StringData with entries like `KeyName = Message with {0} placeholder. (PREFIX0001)`

Applied to files:

  • source/Modules/xRemoteDesktopSessionHost.Common/en-US/xRemoteDesktopSessionHost.Common.strings.psd1
  • source/en-US/xRemoteDesktopSessionHost.strings.psd1
📚 Learning: 2025-09-12T13:20:57.155Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-09-12T13:20:57.155Z
Learning: Applies to source/DSCResources/**/[a-z][a-z]-[A-Z][A-Z]/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/xRemoteDesktopSessionHost.strings.psd1
📚 Learning: 2025-08-29T17:22:23.268Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-localization.instructions.md:0-0
Timestamp: 2025-08-29T17:22:23.268Z
Learning: Applies to source/en-US/*.strings.psd1 : Include string IDs in the form (PREFIX####), where PREFIX is initials from the class/function name and numbers are sequential from 0001

Applied to files:

  • source/en-US/xRemoteDesktopSessionHost.strings.psd1
📚 Learning: 2025-09-16T16:35:31.909Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines.instructions.md:0-0
Timestamp: 2025-09-16T16:35:31.909Z
Learning: Applies to tests/Integration/Commands/*.Integration.Tests.ps1 : Add integration tests for all public commands (and resources)

Applied to files:

  • tests/Unit/MSFT_xRDSessionDeployment.Tests.ps1
📚 Learning: 2025-09-12T13:20:57.155Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-09-12T13:20:57.155Z
Learning: Applies to source/DSCResources/**/*.psm1 : Each of Get-/Set-/Test-TargetResource must include at least one Write-Verbose call

Applied to files:

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

Applied to files:

  • RequiredModules.psd1
⏰ 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). (1)
  • GitHub Check: dsccommunity.xRemoteDesktopSessionHost (Build Package Module)
🔇 Additional comments (20)
source/en-US/xRemoteDesktopSessionHost.strings.psd1 (1)

1-4: LGTM! Empty module-level localization file is acceptable.

Based on learnings, empty module-level localization files are acceptable when DSC resources have their own localization files. Automated tests verify localization completeness for resources.

CHANGELOG.md (1)

35-35: LGTM!

The CHANGELOG entry correctly documents the Pester 5 migration and references the corresponding issue.

source/Modules/xRemoteDesktopSessionHost.Common/en-US/xRemoteDesktopSessionHost.Common.strings.psd1 (1)

1-4: LGTM! Empty localization file is acceptable.

This empty localization file follows the established pattern. Based on learnings, automated tests verify localization completeness.

tests/Unit/MSFT_xRDCertificateConfiguration.Tests.ps1 (1)

1-313: LGTM! Excellent Pester 5 implementation.

This test file correctly follows the required Pester 5 template:

  • Proper SuppressMessage attributes and param()
  • BeforeDiscovery ensures DscResource.Test is available
  • BeforeAll sets up test environment with Initialize-TestEnvironment for MOF resources
  • PSDefaultParameterValues correctly configured
  • Uses Should -Invoke instead of deprecated Assert-MockCalled
  • Proper cleanup in AfterAll
  • Good test coverage for Get-/Test-/Set-TargetResource
RequiredModules.psd1 (2)

12-12: LGTM! Pester version update aligns with migration goals.

Updating Pester to 'latest' ensures compatibility with Pester 5 syntax and features, which is the primary objective of this PR.

Based on learnings.


27-27: LGTM! Adding analyzer rules improves code quality.

The addition of Indented.ScriptAnalyzerRules provides additional static analysis capabilities to maintain code quality.

azure-pipelines.yml (1)

113-113: LGTM! Unit tests now run in PowerShell Core.

This change aligns with the Pester 5 migration objectives and follows the correct pattern where unit tests run in PowerShell 7 (pwsh: true) while HQRM tests continue to run in Windows PowerShell (pwsh: false at line 78).

Based on learnings.

source/DSCResources/MSFT_xRDGatewayConfiguration/MSFT_xRDGatewayConfiguration.psm1 (2)

1-12: LGTM! Consistent module loading pattern.

The refactored module loading approach:

  1. Dynamically resolves the module path
  2. Imports both common modules (xRemoteDesktopSessionHost.Common and DscResource.Common)
  3. Explicitly asserts RemoteDesktop module availability using Assert-Module

This pattern is consistent across all DSC resources in this PR and provides better dependency management.


206-206: LGTM! Named parameters improve clarity.

Using named parameters instead of positional parameters makes the function call more explicit and maintainable.

source/DSCResources/MSFT_xRDLicenseConfiguration/MSFT_xRDLicenseConfiguration.psm1 (1)

1-12: LGTM! Consistent with module-wide refactor pattern.

This resource adopts the same module loading and dependency assertion pattern as other resources in this PR, ensuring consistency across the module.

.vscode/settings.json (1)

48-57: LGTM! VSCode configuration supports Pester 5 workflow.

These settings enable proper Pester 5 test discovery and execution in VSCode:

  • Test file patterns match the repository structure
  • Module path points to the built RequiredModules directory
  • CodeLens and new process settings optimize the testing experience
source/DSCResources/MSFT_xRDServer/MSFT_xRDServer.psm1 (1)

1-13: LGTM! Consistent module loading pattern applied.

This resource follows the same refactored module loading approach as other resources in this PR, ensuring consistent dependency management across the module.

source/DSCResources/MSFT_xRDSessionDeployment/MSFT_xRDSessionDeployment.psm1 (1)

1-12: LGTM! Completes consistent refactor across all DSC resources.

This resource adopts the standardized module loading pattern, completing the refactor across all DSC resources in the module. The consistent approach improves maintainability and dependency management.

source/DSCResources/MSFT_xRDCertificateConfiguration/MSFT_xRDCertificateConfiguration.psm1 (1)

1-6: Good: standardized imports, localization, and module assertion

Use of Get-LocalizedData and Assert-Module -ImportModule looks correct and consistent with DSC guidelines. Please align other resources similarly (RemoteApp/SessionCollection).

As per coding guidelines

Also applies to: 12-12, 42-43, 80-81

source/DSCResources/MSFT_xRDSessionCollection/MSFT_xRDSessionCollection.psm1 (2)

1-6: Dynamic module path + common imports look good

Resolves submodule paths robustly and imports shared utilities as intended. Consider verifying this still resolves correctly from the built module location.


12-12: RemoteDesktop dependency check

Switching to Assert-Module is fine and keeps behavior explicit.

source/DSCResources/MSFT_xRDConnectionBrokerHAMode/MSFT_xRDConnectionBrokerHAMode.psm1 (2)

1-6: Common module path + imports

LGTM. Consistent with other resources and build layout.


12-12: RemoteDesktop dependency assertion

LGTM.

source/Modules/xRemoteDesktopSessionHost.Common/xRemoteDesktopSessionHost.Common.psd1 (1)

12-12: RootModule rename

OK if the psm1 aligns with file system. No action.

build.yaml (1)

22-29: Submodule packaging looks correct

Prefix, copy paths, and exclusions for xRemoteDesktopSessionHost.Common look consistent with import by path in resources/tests.

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

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3427bee and bf748e7.

📒 Files selected for processing (1)
  • Resolve-Dependency.psd1 (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**

⚙️ 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
  • 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:

  • Resolve-Dependency.psd1
{**/*.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 (one per line) with a 1‑line description...

Files:

  • Resolve-Dependency.psd1
🧠 Learnings (1)
📓 Common learnings
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-12T13:21:31.054Z
Learning: Applies to **/*.[Tt]ests.ps1 : Use Pester v5 syntax only
Learnt from: dan-hughes
PR: dsccommunity/ActiveDirectoryDsc#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.
Learnt from: johlju
PR: dsccommunity/SqlServerDsc#2150
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:35-35
Timestamp: 2025-08-28T15:44:12.628Z
Learning: The repository uses RequiredModules.psd1 to specify Pester version requirements with RequiredVersion = 'latest', which ensures compatibility with Should -Invoke syntax (requires Pester 5.4+).
⏰ 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). (4)
  • GitHub Check: dsccommunity.xRemoteDesktopSessionHost (Quality Test and Unit Test Unit Windows Server 2025)
  • GitHub Check: dsccommunity.xRemoteDesktopSessionHost (Quality Test and Unit Test Unit Windows Server 2022)
  • GitHub Check: dsccommunity.xRemoteDesktopSessionHost (Quality Test and Unit Test HQRM)
  • GitHub Check: dsccommunity.xRemoteDesktopSessionHost (Build Package Module)

@dan-hughes
Copy link
Contributor Author

@coderabbitai pause

@coderabbitai
Copy link

coderabbitai bot commented Oct 15, 2025

✅ Actions performed

Reviews paused.

@dan-hughes dan-hughes changed the title Migrate Test to Pester 5 Migrate Tests to Pester 5 Oct 15, 2025
@codecov
Copy link

codecov bot commented Oct 30, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97%. Comparing base (3759521) to head (3318ec3).

Additional details and impacted files

Impacted file tree graph

@@         Coverage Diff         @@
##           main   #122   +/-   ##
===================================
+ Coverage    90%    97%   +7%     
===================================
  Files        10      9    -1     
  Lines       556    539   -17     
===================================
+ Hits        503    526   +23     
+ Misses       53     13   -40     
Files with missing lines Coverage Δ
...onfiguration/MSFT_xRDCertificateConfiguration.psm1 97% <100%> (+<1%) ⬆️
...onBrokerHAMode/MSFT_xRDConnectionBrokerHAMode.psm1 94% <100%> (-3%) ⬇️
...wayConfiguration/MSFT_xRDGatewayConfiguration.psm1 98% <100%> (+8%) ⬆️
...nseConfiguration/MSFT_xRDLicenseConfiguration.psm1 97% <100%> (+21%) ⬆️
...Resources/MSFT_xRDRemoteApp/MSFT_xRDRemoteApp.psm1 98% <100%> (-1%) ⬇️
...ce/DSCResources/MSFT_xRDServer/MSFT_xRDServer.psm1 98% <100%> (+32%) ⬆️
...RDSessionCollection/MSFT_xRDSessionCollection.psm1 98% <100%> (+1%) ⬆️
...ration/MSFT_xRDSessionCollectionConfiguration.psm1 96% <100%> (-1%) ⬇️
...RDSessionDeployment/MSFT_xRDSessionDeployment.psm1 97% <100%> (-1%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dan-hughes
Copy link
Contributor Author

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Oct 30, 2025

✅ Actions performed

Review triggered.

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

@dan-hughes dan-hughes self-assigned this Oct 30, 2025
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: 3

Caution

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

⚠️ Outside diff range comments (5)
source/DSCResources/MSFT_xRDConnectionBrokerHAMode/MSFT_xRDConnectionBrokerHAMode.psm1 (1)

58-64: Return the actual secondary connection string.

Line [63] now sets DatabaseSecondaryConnectionString to the incoming parameter, not the value reported by Get-RDConnectionBrokerHighAvailability. This always mirrors the desired state and hides drift, so Test-TargetResource will return $true even when the cluster’s secondary string differs. Please return the property from the retrieved object instead.

-        DatabaseSecondaryConnectionString = $DatabaseSecondaryConnectionString
+        DatabaseSecondaryConnectionString = $ConnectionBrokerHighAvailability.DatabaseSecondaryConnectionString
source/DSCResources/MSFT_xRDSessionCollection/MSFT_xRDSessionCollection.psm1 (1)

135-138: Restore the CollectionName when removing hosts.

Inside the Force-update path we call Remove-RDSessionHost without -CollectionName, but that parameter is mandatory. At runtime the cmdlet throws a parameter binding error, so the resource never removes surplus hosts. Please include the collection name in the removal call.

-        foreach ($server in $surplus)
-        {
-            Remove-RDSessionHost -ConnectionBroker $ConnectionBroker -SessionHost $server
-        }
+        foreach ($server in $surplus)
+        {
+            Remove-RDSessionHost -ConnectionBroker $ConnectionBroker -CollectionName $CollectionName -SessionHost $server
+        }
source/DSCResources/MSFT_xRDRemoteApp/MSFT_xRDRemoteApp.psm1 (1)

197-208: Skip Set-RDRemoteApp when nothing exists to remove.

When the RemoteApp isn’t deployed and Ensure is Absent, we still fall through to Set-RDRemoteApp @PSBoundParameters, which raises “RemoteApp not found” and breaks idempotence. Bail out in that branch instead of calling Set.

-    elseif ($remoteApp -and $Ensure -eq 'Absent')
-    {
-        Remove-RDRemoteApp -CollectionName $CollectionName -Alias $Alias -Force
-    }
-    else
-    {
-        Set-RDRemoteApp @PSBoundParameters
-    }
+    elseif ($remoteApp -and $Ensure -eq 'Absent')
+    {
+        Remove-RDRemoteApp -CollectionName $CollectionName -Alias $Alias -Force
+    }
+    elseif ($remoteApp)
+    {
+        Set-RDRemoteApp @PSBoundParameters
+    }
source/DSCResources/MSFT_xRDSessionCollectionConfiguration/MSFT_xRDSessionCollectionConfiguration.psm1 (2)

328-352: Throw the ArgumentException so validation actually stops
The new validation branches call New-ArgumentException, but the returned exception is never thrown. As written, the code just logs and then continues into Set-RDSessionCollectionConfiguration with invalid values, which is exactly what this guard was supposed to prevent. Please wrap each New-ArgumentException call in throw (...) so the function terminates when the validation fails.

Apply this diff:

-                if (-not(Test-Path -Path $DiskPath -ErrorAction SilentlyContinue))
-                {
-                    New-ArgumentException -ArgumentName 'DiskPath' -Message ('To enable UserProfileDisk we need a valid DiskPath. Path {0} not found' -f $DiskPath)
-                }
+                if (-not (Test-Path -Path $DiskPath -ErrorAction SilentlyContinue))
+                {
+                    throw (New-ArgumentException -ArgumentName 'DiskPath' -Message ('To enable UserProfileDisk we need a valid DiskPath. Path {0} not found' -f $DiskPath))
+                }
 ...
-                New-ArgumentException -ArgumentName 'DiskPath' -Message 'No value found for parameter DiskPath. This is a mandatory parameter if EnableUserProfileDisk is set to True'
+                throw (New-ArgumentException -ArgumentName 'DiskPath' -Message 'No value found for parameter DiskPath. This is a mandatory parameter if EnableUserProfileDisk is set to True')
 ...
-                New-ArgumentException -ArgumentName 'MaxUserProfileDiskSizeGB' -Message (
-                    'To enable UserProfileDisk we need a setting for MaxUserProfileDiskSizeGB that is greater than 0. Current value {0} is not valid' -f $MaxUserProfileDiskSizeGB
-                )
+                throw (New-ArgumentException -ArgumentName 'MaxUserProfileDiskSizeGB' -Message (
+                        'To enable UserProfileDisk we need a setting for MaxUserProfileDiskSizeGB that is greater than 0. Current value {0} is not valid' -f $MaxUserProfileDiskSizeGB
+                    ))

515-552: Don’t remove parameters you still need to splat into Get-TargetResource
Test-TargetResource now calls Get-TargetResource @PSBoundParameters, but earlier in the function you delete ConnectionBroker and, on down-level OS, even CollectionName from $PSBoundParameters. That creates two regressions:

  1. On Windows Server 2012 R2 (Major < 10) the splatted call is missing the mandatory CollectionName parameter and throws.
  2. Whenever a remote broker is targeted, the connection broker value is dropped, so the comparison silently queries the local broker instead of the one the user specified.

Please keep a separate splat for the Get-TargetResource call (preserving the mandatory key properties) and only remove entries from the hash you pass into Test-DscParameterState.

Apply this diff:

-    $null = $PSBoundParameters.Remove('Verbose')
-    $null = $PSBoundParameters.Remove('Debug')
-    $null = $PSBoundParameters.Remove('ConnectionBroker')
+    $null = $PSBoundParameters.Remove('Verbose')
+    $null = $PSBoundParameters.Remove('Debug')
+
+    $getTargetResourceParams = @{
+        CollectionName = $CollectionName
+    }
+
+    if ($PSBoundParameters.ContainsKey('ConnectionBroker'))
+    {
+        $getTargetResourceParams.ConnectionBroker = $ConnectionBroker
+        $null = $PSBoundParameters.Remove('ConnectionBroker')
+    }
@@
-        $null = $PSBoundParameters.Remove('CollectionName')
+        $null = $PSBoundParameters.Remove('CollectionName')
@@
-    $testDscParameterStateSplat = @{
-        CurrentValues       = Get-TargetResource -CollectionName $CollectionName
+    $testDscParameterStateSplat = @{
+        CurrentValues       = Get-TargetResource @getTargetResourceParams
♻️ Duplicate comments (2)
tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1 (1)

59-121: Remove the legacy commented-out suite.

The entire Pester v4 block is still commented out, which violates our “no commented-out code” guideline and creates maintenance noise. Please delete this obsolete block now that the Pester 5 tests cover the scenarios. As per coding guidelines.

source/Modules/xRemoteDesktopSessionHost.Common/Public/Test-xRemoteDesktopSessionHostOsRequirement.ps1 (1)

1-4: Add required command metadata and help.

This public function still misses the mandated comment-based help, [CmdletBinding()], and [OutputType([System.Boolean])], and it should use the fully qualified [System.Version] constructor. Please bring it in line with the module’s PowerShell guidelines.

+<#
+    .SYNOPSIS
+        Verifies that the operating system meets the Remote Desktop Session Host requirement.
+
+    .DESCRIPTION
+        Returns $true when Get-xRemoteDesktopSessionHostOsVersion reports at least Windows Server 2012 (6.2.9200.0); otherwise returns $false.
+
+    .OUTPUTS
+        System.Boolean
+
+        Indicates whether the OS version is supported.
+#>
 function Test-xRemoteDesktopSessionHostOsRequirement
 {
-    return (Get-xRemoteDesktopSessionHostOsVersion) -ge ([Version]::new(6, 2, 9200, 0))
+    [CmdletBinding()]
+    [OutputType([System.Boolean])]
+    param ()
+
+    return (Get-xRemoteDesktopSessionHostOsVersion) -ge [System.Version]::new(6, 2, 9200, 0)
 }
🧹 Nitpick comments (6)
tests/Unit/MSFT_xRDSessionCollection.Tests.ps1 (1)

21-24: Align dependency hint with noop guidance.

Line 23 still tells contributors to run .\build.ps1 -ResolveDependency -Tasks build, which contradicts the current DSC guidance to use the faster noop task. Please update the message to match the template we use elsewhere.

-        throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -ResolveDependency -Tasks build" first.'
+        throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks noop" first.'

Based on learnings

tests/Unit/MSFT_xRDLicenseConfiguration.Tests.ps1 (1)

21-24: Fix the dependency resolution guidance.

Line [23] still instructs contributors to run . \build.ps1 -ResolveDependency -Tasks build, but the project guidance (and retrieved learnings) require pointing them to the faster noop task. Please update the message accordingly.

-        throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -ResolveDependency -Tasks build" first.'
+        throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -ResolveDependency -Tasks noop" first.'

Based on learnings

tests/Unit/MSFT_xRDSessionCollectionConfiguration.Tests.ps1 (2)

21-24: Fix the dependency resolution guidance.

Line [23] still directs maintainers to run . \build.ps1 -ResolveDependency -Tasks build, but the documented guidance is to use the lighter noop task. Please update the message so it matches the standard template.

-        throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -ResolveDependency -Tasks build" first.'
+        throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -ResolveDependency -Tasks noop" first.'

Based on learnings


606-683: Remove the commented-out legacy tests.

Lines [606-683] are the old Pester v4 suite left commented out. The PowerShell guidelines prohibit keeping commented-out code, so please delete this block entirely now that the Pester 5 implementation is in place.

As per coding guidelines

tests/Unit/MSFT_xRDServer.Tests.ps1 (1)

21-24: Fix the dependency resolution guidance.

Line [23] still references . \build.ps1 -ResolveDependency -Tasks build, but the approved template (per retrieved learnings) tells contributors to run the noop task instead. Please update the string.

-        throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -ResolveDependency -Tasks build" first.'
+        throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -ResolveDependency -Tasks noop" first.'

Based on learnings

tests/Unit/MSFT_xRDGatewayConfiguration.Tests.ps1 (1)

390-390: Update the Describe title to the correct resource.

The final Describe still references MSFT_xRDLicenseConfiguration, which makes the Pester output misleading while you’re exercising the gateway configuration tests. Please rename it to the matching MSFT_xRDGatewayConfiguration scope so failures point at the right resource.

@dan-hughes dan-hughes marked this pull request as ready for review October 30, 2025 18:50
@dan-hughes
Copy link
Contributor Author

@coderabbitai resume

@coderabbitai
Copy link

coderabbitai bot commented Oct 30, 2025

✅ Actions performed

Reviews resumed.

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: 3

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cf79492 and d7c76f8.

📒 Files selected for processing (3)
  • CHANGELOG.md (1 hunks)
  • source/Modules/xRemoteDesktopSessionHost.Common/Public/Test-xRemoteDesktopSessionHostOsRequirement.ps1 (1 hunks)
  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1 (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • CHANGELOG.md
🧰 Additional context used
📓 Path-based instructions (5)
**

⚙️ 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
  • 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/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
  • source/Modules/xRemoteDesktopSessionHost.Common/Public/Test-xRemoteDesktopSessionHostOsRequirement.ps1
tests/[Uu]nit/**/*.[Tt]ests.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 -Force -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:ModuleNam...

Files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.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 (one per line) with a 1‑line description...

Files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
  • source/Modules/xRemoteDesktopSessionHost.Common/Public/Test-xRemoteDesktopSessionHostOsRequirement.ps1
**/*.[Tt]ests.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)
  • 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

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, InModuleScope:ModuleName
  • Omit -ModuleName parameter on Pester commands
  • Never use Mock inside `InModuleSc...

Files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
source/**/*.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/Modules/xRemoteDesktopSessionHost.Common/Public/Test-xRemoteDesktopSessionHostOsRequirement.ps1
🧠 Learnings (47)
📓 Common learnings
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-10-26T13:27:07.728Z
Learning: Applies to **/*.[Tt]ests.ps1 : Use Pester v5 syntax only
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-unit-tests.instructions.md:0-0
Timestamp: 2025-09-16T16:34:44.689Z
Learning: Applies to tests/[Uu]nit/**/*.[Tt]ests.ps1 : Include the exact Pester setup block before Describe: SuppressMessage attribute with param (); BeforeDiscovery to ensure DscResource.Test is available (fallback to build.ps1 -Tasks 'noop') and Import-Module; BeforeAll to set $script:moduleName, import the module, and set PSDefaultParameterValues for InModuleScope/Mock/Should; AfterAll to remove those defaults and unload the tested module
Learnt from: dan-hughes
PR: dsccommunity/UpdateServicesDsc#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: dan-hughes
PR: dsccommunity/ActiveDirectoryDsc#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.
Learnt from: johlju
PR: dsccommunity/SqlServerDsc#2150
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:35-35
Timestamp: 2025-08-28T15:44:12.628Z
Learning: The repository uses RequiredModules.psd1 to specify Pester version requirements with RequiredVersion = 'latest', which ensures compatibility with Should -Invoke syntax (requires Pester 5.4+).
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines.instructions.md:0-0
Timestamp: 2025-09-16T16:35:31.909Z
Learning: Applies to tests/Unit/{Classes,Public,Private}/*.Tests.ps1 : Add unit tests for all commands, functions, and resources
Learnt from: johlju
PR: dsccommunity/SqlServerDsc#2150
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:35-35
Timestamp: 2025-08-28T15:44:12.628Z
Learning: The SqlServerDsc repository uses RequiredModules.psd1 to specify Pester with Version = 'latest' and AllowPrerelease = $true, ensuring the latest Pester version (well beyond 5.4) is available, which supports Should -Invoke syntax and other modern Pester features.
Learnt from: johlju
PR: dsccommunity/SqlServerDsc#2300
File: tests/Unit/DSC_SqlAGDatabase.Tests.ps1:22-22
Timestamp: 2025-10-11T08:35:56.141Z
Learning: In DSC Community projects, when writing error messages for missing DscResource.Test module dependency in unit test files (tests/[Uu]nit/**/*.[Tt]ests.ps1), the policy is: new code should instruct users to run ".\build.ps1 -Tasks noop" for quick test environment setup; existing code using ".\build.ps1 -Tasks build" is acceptable but slower since it also builds the project. The `noop` task is preferred as it assumes the module is already built before running tests, especially when tests run in a separate process.
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-10-26T13:27:07.728Z
Learning: Applies to **/*.[Tt]ests.ps1 : Avoid unnecessary remove/recreate cycles in tests
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-09-12T13:20:57.155Z
Learning: Applies to source/DSCResources/**/*.psm1 : Use localized strings for all messages (e.g., Write-Verbose, Write-Error)
📚 Learning: 2025-09-16T16:34:44.689Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-unit-tests.instructions.md:0-0
Timestamp: 2025-09-16T16:34:44.689Z
Learning: Applies to tests/[Uu]nit/**/*.[Tt]ests.ps1 : Include the exact Pester setup block before Describe: SuppressMessage attribute with param (); BeforeDiscovery to ensure DscResource.Test is available (fallback to build.ps1 -Tasks 'noop') and Import-Module; BeforeAll to set $script:moduleName, import the module, and set PSDefaultParameterValues for InModuleScope/Mock/Should; AfterAll to remove those defaults and unload the tested module

Applied to files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
📚 Learning: 2025-09-16T16:35:31.909Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines.instructions.md:0-0
Timestamp: 2025-09-16T16:35:31.909Z
Learning: Applies to tests/Unit/{Classes,Public,Private}/*.Tests.ps1 : Add unit tests for all commands, functions, and resources

Applied to files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
📚 Learning: 2025-10-12T11:23:30.123Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-10-12T11:23:30.123Z
Learning: Applies to tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1 : Include the required Pester setup block (SuppressMessage param, BeforeDiscovery loading DscResource.Test, and BeforeAll importing the module)

Applied to files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
📚 Learning: 2025-10-12T11:23:30.123Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-10-12T11:23:30.123Z
Learning: Applies to tests/Integration/Resources/*.Integration.Tests.ps1 : Place resource integration tests at tests/Integration/Resources/{ResourceName}.Integration.Tests.ps1

Applied to files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
📚 Learning: 2025-09-16T16:35:31.909Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines.instructions.md:0-0
Timestamp: 2025-09-16T16:35:31.909Z
Learning: Applies to tests/Integration/Commands/*.Integration.Tests.ps1 : Add integration tests for all public commands (and resources)

Applied to files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
📚 Learning: 2025-10-26T13:27:07.728Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-10-26T13:27:07.728Z
Learning: Applies to **/*.[Tt]ests.ps1 : All public commands and class-based resources must have integration tests

Applied to files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
📚 Learning: 2025-08-10T15:11:52.897Z
Learnt from: dan-hughes
PR: dsccommunity/ActiveDirectoryDsc#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/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
  • source/Modules/xRemoteDesktopSessionHost.Common/Public/Test-xRemoteDesktopSessionHostOsRequirement.ps1
📚 Learning: 2025-10-11T08:18:26.062Z
Learnt from: johlju
PR: dsccommunity/SqlServerDsc#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/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
📚 Learning: 2025-10-26T13:26:13.396Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-10-26T13:26:13.396Z
Learning: Applies to tests/Unit/**/*.Tests.ps1 : Unit tests must set $env:SqlServerDscCI = $true in BeforeAll and remove it in AfterAll

Applied to files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
📚 Learning: 2025-10-10T14:01:42.703Z
Learnt from: dan-hughes
PR: dsccommunity/UpdateServicesDsc#86
File: tests/Unit/MSFT_UpdateServicesServer.Tests.ps1:6-45
Timestamp: 2025-10-10T14:01:42.703Z
Learning: For script-based (MOF) DSC resources in UpdateServicesDsc, unit tests should use Initialize-TestEnvironment with variables $script:dscModuleName and $script:dscResourceName, and set -ResourceType 'Mof'. This differs from class-based resource tests which use the simpler $script:moduleName template without Initialize-TestEnvironment.

Applied to files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
📚 Learning: 2025-10-12T11:23:30.123Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-10-12T11:23:30.123Z
Learning: Applies to tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1 : Do not use mocking in integration tests; run against a real environment

Applied to files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
📚 Learning: 2025-10-12T11:23:30.123Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-10-12T11:23:30.123Z
Learning: Applies to tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1 : Call commands with -Force where applicable to avoid prompting

Applied to files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
📚 Learning: 2025-10-26T13:27:07.728Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-10-26T13:27:07.728Z
Learning: Applies to **/*.[Tt]ests.ps1 : Use Pester v5 syntax only

Applied to files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
📚 Learning: 2025-10-26T13:26:13.396Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-10-26T13:26:13.396Z
Learning: Applies to tests/Integration/**/*.Tests.ps1 : Integration tests must use Connect-SqlDscDatabaseEngine with correct CI credentials to open DB sessions

Applied to files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
📚 Learning: 2025-10-26T13:27:07.728Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-10-26T13:27:07.728Z
Learning: Applies to **/*.[Tt]ests.ps1 : Define mocks in BeforeAll; use BeforeEach only when required

Applied to files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
📚 Learning: 2025-10-26T13:27:07.728Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-10-26T13:27:07.728Z
Learning: Applies to **/*.[Tt]ests.ps1 : Never use Assert-MockCalled; use Should -Invoke instead

Applied to files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
📚 Learning: 2025-10-26T13:26:13.397Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-10-26T13:26:13.397Z
Learning: Applies to tests/Integration/**/*.Tests.ps1 : Integration tests must call Disconnect-SqlDscDatabaseEngine after Connect-SqlDscDatabaseEngine

Applied to files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
📚 Learning: 2025-10-26T13:27:07.728Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-10-26T13:27:07.728Z
Learning: Applies to **/*.[Tt]ests.ps1 : Pass all mandatory parameters in tests to avoid prompts

Applied to files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
  • source/Modules/xRemoteDesktopSessionHost.Common/Public/Test-xRemoteDesktopSessionHostOsRequirement.ps1
📚 Learning: 2025-09-16T16:34:44.689Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-unit-tests.instructions.md:0-0
Timestamp: 2025-09-16T16:34:44.689Z
Learning: Applies to tests/[Uu]nit/**/*.[Tt]ests.ps1 : Use the provided Parameter Set Validation test template to assert command ParameterSetName and full parameter list string; for multiple parameter sets, supply multiple hashtables via -ForEach

Applied to files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
📚 Learning: 2025-09-16T16:34:44.689Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-unit-tests.instructions.md:0-0
Timestamp: 2025-09-16T16:34:44.689Z
Learning: Applies to tests/[Uu]nit/**/*.[Tt]ests.ps1 : Use the Parameter Properties template to assert a parameter is mandatory via $parameterInfo = (Get-Command -Name 'CommandName').Parameters['ParameterName']; $parameterInfo.Attributes.Mandatory | Should -BeTrue

Applied to files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
📚 Learning: 2025-09-16T16:34:44.689Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-unit-tests.instructions.md:0-0
Timestamp: 2025-09-16T16:34:44.689Z
Learning: Applies to tests/[Uu]nit/**/*.[Tt]ests.ps1 : All public commands must include parameter set validation tests

Applied to files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
📚 Learning: 2025-08-17T10:15:48.194Z
Learnt from: johlju
PR: dsccommunity/SqlServerDsc#2136
File: tests/Unit/Public/Remove-SqlDscLogin.Tests.ps1:36-39
Timestamp: 2025-08-17T10:15:48.194Z
Learning: Public command unit tests guideline: Never use InModuleScope unless accessing localized strings from $script:localizedData. PSDefaultParameterValues for InModuleScope should be kept in public command tests to support localized string retrieval when necessary.

Applied to files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
📚 Learning: 2025-10-12T11:23:30.123Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-10-12T11:23:30.123Z
Learning: Applies to tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1 : Avoid using -ExpectedMessage with Should -Throw assertions

Applied to files:

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

Applied to files:

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

Applied to files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
📚 Learning: 2025-10-04T21:33:23.022Z
Learnt from: dan-hughes
PR: dsccommunity/UpdateServicesDsc#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:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
📚 Learning: 2025-09-16T16:35:31.909Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines.instructions.md:0-0
Timestamp: 2025-09-16T16:35:31.909Z
Learning: Applies to **/*.ps1 : Follow PowerShell style and test guideline instructions strictly

Applied to files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
  • source/Modules/xRemoteDesktopSessionHost.Common/Public/Test-xRemoteDesktopSessionHostOsRequirement.ps1
📚 Learning: 2025-10-03T15:27:39.511Z
Learnt from: Borgquite
PR: dsccommunity/UpdateServicesDsc#78
File: source/DSCResources/MSFT_UpdateServicesComputerTargetGroup/MSFT_UpdateServicesComputerTargetGroup.psm1:91-109
Timestamp: 2025-10-03T15:27:39.511Z
Learning: For MOF-based DSC resources in DSC Community repositories (files matching `source/DSCResources/MSFT_*/MSFT_*.psm1`), the comment-based help for `Get-TargetResource`, `Set-TargetResource`, and `Test-TargetResource` functions should NOT include `.OUTPUTS` sections, even though the general PowerShell guidelines require them. This is an established pattern in the DSC Community.

Applied to files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
📚 Learning: 2025-09-12T13:20:57.155Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-09-12T13:20:57.155Z
Learning: Applies to source/DSCResources/**/*.psm1 : Test-TargetResource must return a boolean ($true/$false)

Applied to files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
📚 Learning: 2025-10-11T08:35:56.141Z
Learnt from: johlju
PR: dsccommunity/SqlServerDsc#2300
File: tests/Unit/DSC_SqlAGDatabase.Tests.ps1:22-22
Timestamp: 2025-10-11T08:35:56.141Z
Learning: In DSC Community projects, when writing error messages for missing DscResource.Test module dependency in unit test files (tests/[Uu]nit/**/*.[Tt]ests.ps1), the policy is: new code should instruct users to run ".\build.ps1 -Tasks noop" for quick test environment setup; existing code using ".\build.ps1 -Tasks build" is acceptable but slower since it also builds the project. The `noop` task is preferred as it assumes the module is already built before running tests, especially when tests run in a separate process.

Applied to files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
📚 Learning: 2025-09-12T13:20:57.155Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-09-12T13:20:57.155Z
Learning: Applies to source/DSCResources/**/*.psm1 : Set-TargetResource and Test-TargetResource must have identical parameters

Applied to files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
📚 Learning: 2025-09-12T13:20:57.155Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-09-12T13:20:57.155Z
Learning: Applies to source/DSCResources/**/*.psm1 : Set-TargetResource must not return anything (void)

Applied to files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
📚 Learning: 2025-09-12T13:20:57.155Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-09-12T13:20:57.155Z
Learning: Applies to source/DSCResources/**/*.psm1 : Every MOF DSC resource module must define the functions: Get-TargetResource, Set-TargetResource, and Test-TargetResource

Applied to files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
📚 Learning: 2025-09-12T13:20:57.155Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-09-12T13:20:57.155Z
Learning: Applies to source/DSCResources/**/*.psm1 : Test-TargetResource: Write-Verbose message should start with "Determining the current state of..."

Applied to files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
📚 Learning: 2025-09-12T13:20:57.155Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-09-12T13:20:57.155Z
Learning: Applies to source/DSCResources/**/*.psm1 : Each of Get-/Set-/Test-TargetResource must include at least one Write-Verbose call

Applied to files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
📚 Learning: 2025-09-12T13:20:57.155Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-09-12T13:20:57.155Z
Learning: Applies to source/DSCResources/**/*.psm1 : Set-TargetResource: Write-Verbose message should start with "Setting the desired state of..."

Applied to files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
📚 Learning: 2025-09-12T13:20:57.155Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-09-12T13:20:57.155Z
Learning: Applies to source/DSCResources/**/*.psm1 : Get-TargetResource must return a hashtable containing all resource properties

Applied to files:

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

Applied to files:

  • source/Modules/xRemoteDesktopSessionHost.Common/Public/Test-xRemoteDesktopSessionHostOsRequirement.ps1
📚 Learning: 2025-09-12T13:20:14.850Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-class-resource.instructions.md:0-0
Timestamp: 2025-09-12T13:20:14.850Z
Learning: Applies to source/[cC]lasses/**/*.ps1 : Implement [System.Boolean] Test() that calls ([ResourceBase] $this).Test() and returns the result

Applied to files:

  • source/Modules/xRemoteDesktopSessionHost.Common/Public/Test-xRemoteDesktopSessionHostOsRequirement.ps1
📚 Learning: 2025-09-12T13:20:14.850Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-class-resource.instructions.md:0-0
Timestamp: 2025-09-12T13:20:14.850Z
Learning: Applies to source/[cC]lasses/**/*.ps1 : Comment-based help .DESCRIPTION must include '## Requirements'

Applied to files:

  • source/Modules/xRemoteDesktopSessionHost.Common/Public/Test-xRemoteDesktopSessionHostOsRequirement.ps1
📚 Learning: 2025-10-26T13:28:23.439Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-10-26T13:28:23.439Z
Learning: Applies to **/*.{ps1,psm1} : Comment-based help must include SYNOPSIS, DESCRIPTION (40+ chars), PARAMETER, EXAMPLE sections before function/class

Applied to files:

  • source/Modules/xRemoteDesktopSessionHost.Common/Public/Test-xRemoteDesktopSessionHostOsRequirement.ps1
📚 Learning: 2025-10-26T13:28:23.439Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-10-26T13:28:23.439Z
Learning: Applies to **/*.{ps1,psm1} : For state-changing functions, use SupportsShouldProcess with immediate ShouldProcess checks before each change, set ConfirmImpact, follow required pattern, avoid Write-Verbose inside the block

Applied to files:

  • source/Modules/xRemoteDesktopSessionHost.Common/Public/Test-xRemoteDesktopSessionHostOsRequirement.ps1
📚 Learning: 2025-09-12T13:20:57.155Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-09-12T13:20:57.155Z
Learning: Applies to source/DSCResources/**/*.psm1 : For unused mandatory parameters in Set-TargetResource or Test-TargetResource, add a help comment: "Not used in <function_name>"

Applied to files:

  • source/Modules/xRemoteDesktopSessionHost.Common/Public/Test-xRemoteDesktopSessionHostOsRequirement.ps1
📚 Learning: 2025-10-26T13:28:23.439Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-10-26T13:28:23.439Z
Learning: Applies to **/*.{ps1,psm1} : Always add comment-based help to all functions and scripts

Applied to files:

  • source/Modules/xRemoteDesktopSessionHost.Common/Public/Test-xRemoteDesktopSessionHostOsRequirement.ps1
📚 Learning: 2025-10-26T13:27:07.728Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-10-26T13:27:07.728Z
Learning: Applies to **/*.[Tt]ests.ps1 : All public commands, private functions and classes must have unit tests

Applied to files:

  • source/Modules/xRemoteDesktopSessionHost.Common/Public/Test-xRemoteDesktopSessionHostOsRequirement.ps1
📚 Learning: 2025-09-12T13:20:14.850Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-class-resource.instructions.md:0-0
Timestamp: 2025-09-12T13:20:14.850Z
Learning: Applies to source/[cC]lasses/**/*.ps1 : Comment-based help .DESCRIPTION must include '## Known issues' with link text: All issues are not listed here, see [all open issues](https://github.com/{owner}/{repo}/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+{ResourceName}).

Applied to files:

  • source/Modules/xRemoteDesktopSessionHost.Common/Public/Test-xRemoteDesktopSessionHostOsRequirement.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). (1)
  • GitHub Check: dsccommunity.xRemoteDesktopSessionHost (Build Package Module)
🔇 Additional comments (3)
source/Modules/xRemoteDesktopSessionHost.Common/Public/Test-xRemoteDesktopSessionHostOsRequirement.ps1 (1)

14-21: LGTM! Function implementation is correct.

All issues from the previous review have been addressed:

  • Comment-based help has been added
  • [CmdletBinding()] and [OutputType()] attributes are present
  • Using ::new() instead of New-Object

The function logic correctly compares the OS version against the Windows Server 2012 baseline.

tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1 (2)

243-269: LGTM!

The Set-TargetResource tests correctly mock dependencies, assign the result to $null, and verify invocations using Should -Invoke.


145-176: ****

The test assertion at line 169 is correct. The Get-TargetResource implementation explicitly returns DatabaseSecondaryConnectionString from the input parameter (not from Get-RDConnectionBrokerHighAvailability), while all other properties are sourced from the mock output. When the mock returns $null, the properties from the mock become null/empty, but DatabaseSecondaryConnectionString correctly returns the input parameter value as implemented.

Likely an incorrect or invalid review comment.

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: 0

♻️ Duplicate comments (1)
tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1 (1)

23-23: Update error message to reference the 'noop' task.

The error message should instruct users to run .\build.ps1 -Tasks noop (not build) for quick test environment setup.

Based on learnings

Apply this diff:

-        throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -ResolveDependency -Tasks build" first.'
+        throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -ResolveDependency -Tasks noop" first.'
🧹 Nitpick comments (1)
source/Modules/xRemoteDesktopSessionHost.Common/Public/Test-xRemoteDesktopSessionHostOsRequirement.ps1 (1)

14-14: Adjust EXAMPLE section indentation to match guidelines.

The text in the EXAMPLE section uses 7 spaces of indentation instead of the required 8 spaces. Per the coding guidelines, comment-based help text should be indented with 8 spaces.

Apply this diff to fix the indentation:

     .EXAMPLE
-       Test-xRemoteDesktopSessionHostOsRequirement
+        Test-xRemoteDesktopSessionHostOsRequirement

-       Returns $true if the OS is Windows Server 2012 or later, otherwise $false.
+        Returns $true if the OS is Windows Server 2012 or later, otherwise $false.
 #>

Also applies to: 16-16

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d7c76f8 and eb1a0a2.

📒 Files selected for processing (2)
  • source/Modules/xRemoteDesktopSessionHost.Common/Public/Test-xRemoteDesktopSessionHostOsRequirement.ps1 (1 hunks)
  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1 (1 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
**

⚙️ 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
  • 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/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
  • source/Modules/xRemoteDesktopSessionHost.Common/Public/Test-xRemoteDesktopSessionHostOsRequirement.ps1
tests/[Uu]nit/**/*.[Tt]ests.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 -Force -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:ModuleNam...

Files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.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 (one per line) with a 1‑line description...

Files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
  • source/Modules/xRemoteDesktopSessionHost.Common/Public/Test-xRemoteDesktopSessionHostOsRequirement.ps1
**/*.[Tt]ests.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)
  • 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

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, InModuleScope:ModuleName
  • Omit -ModuleName parameter on Pester commands
  • Never use Mock inside `InModuleSc...

Files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
source/**/*.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/Modules/xRemoteDesktopSessionHost.Common/Public/Test-xRemoteDesktopSessionHostOsRequirement.ps1
🧠 Learnings (59)
📓 Common learnings
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-10-26T13:27:07.728Z
Learning: Applies to **/*.[Tt]ests.ps1 : Use Pester v5 syntax only
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.
Learnt from: dan-hughes
Repo: dsccommunity/UpdateServicesDsc PR: 85
File: source/en-US/UpdateServicesDsc.strings.psd1:1-2
Timestamp: 2025-10-04T21:33:23.022Z
Learning: In UpdateServicesDsc (and similar DSC modules), the module-level localization file (source/en-US/<ModuleName>.strings.psd1) can be empty when DSC resources have their own localization files in source/DSCResources/<ResourceName>/en-US/DSC_<ResourceName>.strings.psd1. Automated tests verify localization completeness for resources. Don't flag empty module-level localization files as issues when resources have separate localization.
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-unit-tests.instructions.md:0-0
Timestamp: 2025-09-16T16:34:44.689Z
Learning: Applies to tests/[Uu]nit/**/*.[Tt]ests.ps1 : Include the exact Pester setup block before Describe: SuppressMessage attribute with param (); BeforeDiscovery to ensure DscResource.Test is available (fallback to build.ps1 -Tasks 'noop') and Import-Module; BeforeAll to set $script:moduleName, import the module, and set PSDefaultParameterValues for InModuleScope/Mock/Should; AfterAll to remove those defaults and unload the tested module
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-09-12T13:20:57.155Z
Learning: Applies to source/DSCResources/**/*.psm1 : Use localized strings for all messages (e.g., Write-Verbose, Write-Error)
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 2300
File: tests/Unit/DSC_SqlAGDatabase.Tests.ps1:22-22
Timestamp: 2025-10-11T08:35:56.141Z
Learning: In DSC Community projects, when writing error messages for missing DscResource.Test module dependency in unit test files (tests/[Uu]nit/**/*.[Tt]ests.ps1), the policy is: new code should instruct users to run ".\build.ps1 -Tasks noop" for quick test environment setup; existing code using ".\build.ps1 -Tasks build" is acceptable but slower since it also builds the project. The `noop` task is preferred as it assumes the module is already built before running tests, especially when tests run in a separate process.
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 2150
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:35-35
Timestamp: 2025-08-28T15:44:12.628Z
Learning: The repository uses RequiredModules.psd1 to specify Pester version requirements with RequiredVersion = 'latest', which ensures compatibility with Should -Invoke syntax (requires Pester 5.4+).
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-09-12T13:20:57.155Z
Learning: Applies to source/DSCResources/**/*.psm1 : Import localized strings at the top of the module using Get-LocalizedData
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-10-26T13:27:07.728Z
Learning: Applies to **/*.[Tt]ests.ps1 : Avoid unnecessary remove/recreate cycles in tests
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.
📚 Learning: 2025-09-16T16:34:44.689Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-unit-tests.instructions.md:0-0
Timestamp: 2025-09-16T16:34:44.689Z
Learning: Applies to tests/[Uu]nit/**/*.[Tt]ests.ps1 : Include the exact Pester setup block before Describe: SuppressMessage attribute with param (); BeforeDiscovery to ensure DscResource.Test is available (fallback to build.ps1 -Tasks 'noop') and Import-Module; BeforeAll to set $script:moduleName, import the module, and set PSDefaultParameterValues for InModuleScope/Mock/Should; AfterAll to remove those defaults and unload the tested module

Applied to files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
📚 Learning: 2025-09-16T16:35:31.909Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines.instructions.md:0-0
Timestamp: 2025-09-16T16:35:31.909Z
Learning: Applies to tests/Unit/{Classes,Public,Private}/*.Tests.ps1 : Add unit tests for all commands, functions, and resources

Applied to files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
📚 Learning: 2025-10-12T11:23:30.123Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-10-12T11:23:30.123Z
Learning: Applies to tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1 : Include the required Pester setup block (SuppressMessage param, BeforeDiscovery loading DscResource.Test, and BeforeAll importing the module)

Applied to files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
📚 Learning: 2025-10-12T11:23:30.123Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-10-12T11:23:30.123Z
Learning: Applies to tests/Integration/Resources/*.Integration.Tests.ps1 : Place resource integration tests at tests/Integration/Resources/{ResourceName}.Integration.Tests.ps1

Applied to files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
📚 Learning: 2025-09-16T16:35:31.909Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines.instructions.md:0-0
Timestamp: 2025-09-16T16:35:31.909Z
Learning: Applies to tests/Integration/Commands/*.Integration.Tests.ps1 : Add integration tests for all public commands (and resources)

Applied to files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
📚 Learning: 2025-10-26T13:27:07.728Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-10-26T13:27:07.728Z
Learning: Applies to **/*.[Tt]ests.ps1 : All public commands and class-based resources must have integration tests

Applied to files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
📚 Learning: 2025-10-26T13:27:07.728Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-10-26T13:27:07.728Z
Learning: Applies to tests/Unit/Classes/*.Tests.ps1 : Place class resource unit tests under tests/Unit/Classes/{Name}.Tests.ps1

Applied to files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
📚 Learning: 2025-10-10T14:01:42.703Z
Learnt from: dan-hughes
Repo: dsccommunity/UpdateServicesDsc PR: 86
File: tests/Unit/MSFT_UpdateServicesServer.Tests.ps1:6-45
Timestamp: 2025-10-10T14:01:42.703Z
Learning: For script-based (MOF) DSC resources in UpdateServicesDsc, unit tests should use Initialize-TestEnvironment with variables $script:dscModuleName and $script:dscResourceName, and set -ResourceType 'Mof'. This differs from class-based resource tests which use the simpler $script:moduleName template without Initialize-TestEnvironment.

Applied to files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
📚 Learning: 2025-10-26T13:26:13.396Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-10-26T13:26:13.396Z
Learning: Applies to tests/Unit/**/*.Tests.ps1 : Unit tests must set $env:SqlServerDscCI = $true in BeforeAll and remove it in AfterAll

Applied to files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.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/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
  • source/Modules/xRemoteDesktopSessionHost.Common/Public/Test-xRemoteDesktopSessionHostOsRequirement.ps1
📚 Learning: 2025-10-12T11:23:30.123Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-10-12T11:23:30.123Z
Learning: Applies to tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1 : Do not use mocking in integration tests; run against a real environment

Applied to files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
📚 Learning: 2025-10-12T11:23:30.123Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-10-12T11:23:30.123Z
Learning: Applies to tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1 : Call commands with -Force where applicable to avoid prompting

Applied to files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
📚 Learning: 2025-10-26T13:27:07.728Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-10-26T13:27:07.728Z
Learning: Applies to **/*.[Tt]ests.ps1 : Use Pester v5 syntax only

Applied to files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
📚 Learning: 2025-10-26T13:26:13.396Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-10-26T13:26:13.396Z
Learning: Applies to tests/Integration/**/*.Tests.ps1 : Integration tests must use Connect-SqlDscDatabaseEngine with correct CI credentials to open DB sessions

Applied to files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
📚 Learning: 2025-10-26T13:27:07.728Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-10-26T13:27:07.728Z
Learning: Applies to **/*.[Tt]ests.ps1 : Define mocks in BeforeAll; use BeforeEach only when required

Applied to files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
📚 Learning: 2025-10-26T13:27:07.728Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-10-26T13:27:07.728Z
Learning: Applies to **/*.[Tt]ests.ps1 : Never use Assert-MockCalled; use Should -Invoke instead

Applied to files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
📚 Learning: 2025-10-26T13:26:13.397Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-10-26T13:26:13.397Z
Learning: Applies to tests/Integration/**/*.Tests.ps1 : Integration tests must call Disconnect-SqlDscDatabaseEngine after Connect-SqlDscDatabaseEngine

Applied to files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
📚 Learning: 2025-10-26T13:27:07.728Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-10-26T13:27:07.728Z
Learning: Applies to **/*.[Tt]ests.ps1 : Pass all mandatory parameters in tests to avoid prompts

Applied to files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
  • source/Modules/xRemoteDesktopSessionHost.Common/Public/Test-xRemoteDesktopSessionHostOsRequirement.ps1
📚 Learning: 2025-09-16T16:34:44.689Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-unit-tests.instructions.md:0-0
Timestamp: 2025-09-16T16:34:44.689Z
Learning: Applies to tests/[Uu]nit/**/*.[Tt]ests.ps1 : Use the provided Parameter Set Validation test template to assert command ParameterSetName and full parameter list string; for multiple parameter sets, supply multiple hashtables via -ForEach

Applied to files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
📚 Learning: 2025-09-16T16:34:44.689Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-unit-tests.instructions.md:0-0
Timestamp: 2025-09-16T16:34:44.689Z
Learning: Applies to tests/[Uu]nit/**/*.[Tt]ests.ps1 : Use the Parameter Properties template to assert a parameter is mandatory via $parameterInfo = (Get-Command -Name 'CommandName').Parameters['ParameterName']; $parameterInfo.Attributes.Mandatory | Should -BeTrue

Applied to files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
📚 Learning: 2025-09-16T16:34:44.689Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-unit-tests.instructions.md:0-0
Timestamp: 2025-09-16T16:34:44.689Z
Learning: Applies to tests/[Uu]nit/**/*.[Tt]ests.ps1 : All public commands must include parameter set validation tests

Applied to files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
📚 Learning: 2025-08-17T10:15:48.194Z
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 2136
File: tests/Unit/Public/Remove-SqlDscLogin.Tests.ps1:36-39
Timestamp: 2025-08-17T10:15:48.194Z
Learning: Public command unit tests guideline: Never use InModuleScope unless accessing localized strings from $script:localizedData. PSDefaultParameterValues for InModuleScope should be kept in public command tests to support localized string retrieval when necessary.

Applied to files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
📚 Learning: 2025-10-12T11:23:30.123Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-10-12T11:23:30.123Z
Learning: Applies to tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1 : Avoid using -ExpectedMessage with Should -Throw assertions

Applied to files:

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

Applied to files:

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

Applied to files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
📚 Learning: 2025-10-04T21:33:23.022Z
Learnt from: dan-hughes
Repo: dsccommunity/UpdateServicesDsc PR: 85
File: source/en-US/UpdateServicesDsc.strings.psd1:1-2
Timestamp: 2025-10-04T21:33:23.022Z
Learning: In UpdateServicesDsc (and similar DSC modules), the module-level localization file (source/en-US/<ModuleName>.strings.psd1) can be empty when DSC resources have their own localization files in source/DSCResources/<ResourceName>/en-US/DSC_<ResourceName>.strings.psd1. Automated tests verify localization completeness for resources. Don't flag empty module-level localization files as issues when resources have separate localization.

Applied to files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
📚 Learning: 2025-09-16T16:35:31.909Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines.instructions.md:0-0
Timestamp: 2025-09-16T16:35:31.909Z
Learning: Applies to **/*.ps1 : Follow PowerShell style and test guideline instructions strictly

Applied to files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
  • source/Modules/xRemoteDesktopSessionHost.Common/Public/Test-xRemoteDesktopSessionHostOsRequirement.ps1
📚 Learning: 2025-10-03T15:27:39.511Z
Learnt from: Borgquite
Repo: dsccommunity/UpdateServicesDsc PR: 78
File: source/DSCResources/MSFT_UpdateServicesComputerTargetGroup/MSFT_UpdateServicesComputerTargetGroup.psm1:91-109
Timestamp: 2025-10-03T15:27:39.511Z
Learning: For MOF-based DSC resources in DSC Community repositories (files matching `source/DSCResources/MSFT_*/MSFT_*.psm1`), the comment-based help for `Get-TargetResource`, `Set-TargetResource`, and `Test-TargetResource` functions should NOT include `.OUTPUTS` sections, even though the general PowerShell guidelines require them. This is an established pattern in the DSC Community.

Applied to files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
  • source/Modules/xRemoteDesktopSessionHost.Common/Public/Test-xRemoteDesktopSessionHostOsRequirement.ps1
📚 Learning: 2025-09-12T13:20:57.155Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-09-12T13:20:57.155Z
Learning: Applies to source/DSCResources/**/*.psm1 : Test-TargetResource must return a boolean ($true/$false)

Applied to files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
📚 Learning: 2025-10-11T08:35:56.141Z
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 2300
File: tests/Unit/DSC_SqlAGDatabase.Tests.ps1:22-22
Timestamp: 2025-10-11T08:35:56.141Z
Learning: In DSC Community projects, when writing error messages for missing DscResource.Test module dependency in unit test files (tests/[Uu]nit/**/*.[Tt]ests.ps1), the policy is: new code should instruct users to run ".\build.ps1 -Tasks noop" for quick test environment setup; existing code using ".\build.ps1 -Tasks build" is acceptable but slower since it also builds the project. The `noop` task is preferred as it assumes the module is already built before running tests, especially when tests run in a separate process.

Applied to files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.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/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
📚 Learning: 2025-10-26T13:26:13.396Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-10-26T13:26:13.396Z
Learning: Initialize build/test environment per pwsh session using ./build.ps1 -Tasks noop

Applied to files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
📚 Learning: 2025-09-16T16:35:31.909Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines.instructions.md:0-0
Timestamp: 2025-09-16T16:35:31.909Z
Learning: Setup build and test environment once per pwsh session using ./build.ps1 -Tasks noop

Applied to files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.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/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
📚 Learning: 2025-09-12T13:20:57.155Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-09-12T13:20:57.155Z
Learning: Applies to source/DSCResources/**/*.psm1 : Do not use throw for terminating errors; instead use New-*Exception helper commands (e.g., New-InvalidDataException, New-ArgumentException, New-InvalidOperationException, New-ObjectNotFoundException, New-InvalidResultException, New-NotImplementedException)

Applied to files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
📚 Learning: 2025-10-26T13:27:07.728Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-10-26T13:27:07.728Z
Learning: Applies to **/*.[Tt]ests.ps1 : Context descriptions must start with 'When'

Applied to files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
📚 Learning: 2025-09-12T13:20:57.155Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-09-12T13:20:57.155Z
Learning: Applies to source/DSCResources/**/*.psm1 : Test-TargetResource: Write-Verbose message should start with "Determining the current state of..."

Applied to files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
📚 Learning: 2025-09-12T13:20:57.155Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-09-12T13:20:57.155Z
Learning: Applies to source/DSCResources/**/*.psm1 : Set-TargetResource: Write-Verbose message should start with "Setting the desired state of..."

Applied to files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
📚 Learning: 2025-09-12T13:20:57.155Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-09-12T13:20:57.155Z
Learning: Applies to source/DSCResources/**/*.psm1 : Get-TargetResource: Write-Verbose message should start with "Getting the current state of..."

Applied to files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
📚 Learning: 2025-09-12T13:20:57.155Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-09-12T13:20:57.155Z
Learning: Applies to source/DSCResources/**/*.psm1 : Set-TargetResource and Test-TargetResource must have identical parameters

Applied to files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
📚 Learning: 2025-10-26T13:27:07.728Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-10-26T13:27:07.728Z
Learning: Applies to **/*.[Tt]ests.ps1 : It descriptions must start with 'Should' and must not contain 'when'

Applied to files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
📚 Learning: 2025-09-12T13:20:57.155Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-09-12T13:20:57.155Z
Learning: Applies to source/DSCResources/**/*.psm1 : Set-TargetResource must not return anything (void)

Applied to files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
📚 Learning: 2025-09-12T13:20:57.155Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-09-12T13:20:57.155Z
Learning: Applies to source/DSCResources/**/*.psm1 : Every MOF DSC resource module must define the functions: Get-TargetResource, Set-TargetResource, and Test-TargetResource

Applied to files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
📚 Learning: 2025-09-12T13:20:57.155Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-09-12T13:20:57.155Z
Learning: Applies to source/DSCResources/**/*.psm1 : Each of Get-/Set-/Test-TargetResource must include at least one Write-Verbose call

Applied to files:

  • tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1
📚 Learning: 2025-09-12T13:20:57.155Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-09-12T13:20:57.155Z
Learning: Applies to source/DSCResources/**/*.psm1 : Get-TargetResource must return a hashtable containing all resource properties

Applied to files:

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

Applied to files:

  • source/Modules/xRemoteDesktopSessionHost.Common/Public/Test-xRemoteDesktopSessionHostOsRequirement.ps1
📚 Learning: 2025-09-12T13:20:14.850Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-class-resource.instructions.md:0-0
Timestamp: 2025-09-12T13:20:14.850Z
Learning: Applies to source/[cC]lasses/**/*.ps1 : Implement [System.Boolean] Test() that calls ([ResourceBase] $this).Test() and returns the result

Applied to files:

  • source/Modules/xRemoteDesktopSessionHost.Common/Public/Test-xRemoteDesktopSessionHostOsRequirement.ps1
📚 Learning: 2025-09-12T13:20:14.850Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-class-resource.instructions.md:0-0
Timestamp: 2025-09-12T13:20:14.850Z
Learning: Applies to source/[cC]lasses/**/*.ps1 : Comment-based help .DESCRIPTION must include '## Requirements'

Applied to files:

  • source/Modules/xRemoteDesktopSessionHost.Common/Public/Test-xRemoteDesktopSessionHostOsRequirement.ps1
📚 Learning: 2025-10-26T13:28:23.439Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-10-26T13:28:23.439Z
Learning: Applies to **/*.{ps1,psm1} : Comment-based help must include SYNOPSIS, DESCRIPTION (40+ chars), PARAMETER, EXAMPLE sections before function/class

Applied to files:

  • source/Modules/xRemoteDesktopSessionHost.Common/Public/Test-xRemoteDesktopSessionHostOsRequirement.ps1
📚 Learning: 2025-10-26T13:28:23.439Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-10-26T13:28:23.439Z
Learning: Applies to **/*.{ps1,psm1} : For state-changing functions, use SupportsShouldProcess with immediate ShouldProcess checks before each change, set ConfirmImpact, follow required pattern, avoid Write-Verbose inside the block

Applied to files:

  • source/Modules/xRemoteDesktopSessionHost.Common/Public/Test-xRemoteDesktopSessionHostOsRequirement.ps1
📚 Learning: 2025-09-12T13:20:57.155Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-09-12T13:20:57.155Z
Learning: Applies to source/DSCResources/**/*.psm1 : For unused mandatory parameters in Set-TargetResource or Test-TargetResource, add a help comment: "Not used in <function_name>"

Applied to files:

  • source/Modules/xRemoteDesktopSessionHost.Common/Public/Test-xRemoteDesktopSessionHostOsRequirement.ps1
📚 Learning: 2025-10-26T13:28:23.439Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-10-26T13:28:23.439Z
Learning: Applies to **/*.{ps1,psm1} : Always add comment-based help to all functions and scripts

Applied to files:

  • source/Modules/xRemoteDesktopSessionHost.Common/Public/Test-xRemoteDesktopSessionHostOsRequirement.ps1
📚 Learning: 2025-10-26T13:27:07.728Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-10-26T13:27:07.728Z
Learning: Applies to **/*.[Tt]ests.ps1 : All public commands, private functions and classes must have unit tests

Applied to files:

  • source/Modules/xRemoteDesktopSessionHost.Common/Public/Test-xRemoteDesktopSessionHostOsRequirement.ps1
📚 Learning: 2025-09-12T13:20:14.850Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-class-resource.instructions.md:0-0
Timestamp: 2025-09-12T13:20:14.850Z
Learning: Applies to source/[cC]lasses/**/*.ps1 : Comment-based help .DESCRIPTION must include '## Known issues' with link text: All issues are not listed here, see [all open issues](https://github.com/{owner}/{repo}/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+{ResourceName}).

Applied to files:

  • source/Modules/xRemoteDesktopSessionHost.Common/Public/Test-xRemoteDesktopSessionHostOsRequirement.ps1
📚 Learning: 2025-10-26T13:28:23.439Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-10-26T13:28:23.439Z
Learning: Applies to **/*.{ps1,psm1} : Include examples for all parameter sets and combinations in comment-based help

Applied to files:

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

Applied to files:

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

Applied to files:

  • source/Modules/xRemoteDesktopSessionHost.Common/Public/Test-xRemoteDesktopSessionHostOsRequirement.ps1
📚 Learning: 2025-10-03T15:27:24.417Z
Learnt from: Borgquite
Repo: dsccommunity/UpdateServicesDsc PR: 78
File: source/DSCResources/MSFT_UpdateServicesComputerTargetGroup/MSFT_UpdateServicesComputerTargetGroup.psm1:9-22
Timestamp: 2025-10-03T15:27:24.417Z
Learning: In the UpdateServicesDsc repository, MOF-based DSC resources follow a minimal comment-based help convention that includes only .SYNOPSIS and .PARAMETER sections. The .DESCRIPTION, .INPUTS, and .OUTPUTS sections are intentionally omitted, even though functions have [OutputType()] attributes. This is consistent across all existing DSC resources: MSFT_UpdateServicesServer, MSFT_UpdateServicesCleanup, and MSFT_UpdateServicesApprovalRule.

Applied to files:

  • source/Modules/xRemoteDesktopSessionHost.Common/Public/Test-xRemoteDesktopSessionHostOsRequirement.ps1
🔇 Additional comments (2)
source/Modules/xRemoteDesktopSessionHost.Common/Public/Test-xRemoteDesktopSessionHostOsRequirement.ps1 (1)

19-26: LGTM! Function implementation is correct and addresses all previous feedback.

The function properly implements the OS requirement check with all required elements:

  • Complete comment-based help with SYNOPSIS, DESCRIPTION, OUTPUTS, and EXAMPLE sections
  • [CmdletBinding()] and [OutputType([System.Boolean])] attributes
  • Uses [System.Version]::new() static method instead of New-Object
  • Returns a consistent boolean type matching the declared output type

The logic correctly verifies that the OS version is at least Windows Server 2012 (6.2.9200.0).

tests/Unit/MSFT_xRDConnectionBrokerHAMode.Tests.ps1 (1)

1-269: LGTM! Well-structured Pester 5 migration.

The test file correctly:

  • Uses the MOF resource testing pattern with Initialize-TestEnvironment and Restore-TestEnvironment
  • Follows Pester 5 syntax with Should -Invoke, proper Context/It descriptions, and BeforeAll/AfterAll blocks
  • Tests all three required MOF resource functions with appropriate scenarios
  • Uses InModuleScope correctly for MOF resource testing
  • Sets PSDefaultParameterValues for Pester commands

The migration to Pester 5 is complete and well-executed.

@dan-hughes dan-hughes requested a review from raandree October 31, 2025 09:15
@dan-hughes dan-hughes added tests The issue or pull request is about tests only. needs review The pull request needs a code review. labels Oct 31, 2025
@dan-hughes
Copy link
Contributor Author

@raandree, would you be able to review please?

Focus on the DSC resource changes specifically, some of it just wasn't compatible with Pester 5 and other parts look to have been written before some of the DSC helper functions existed.

I am building a lab to test this against before a release can be made.

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. tests The issue or pull request is about tests only.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate tests to Pester 5

1 participant