Get-SqlDscLogin: command to retrieve SQL Server logins#2134
Get-SqlDscLogin: command to retrieve SQL Server logins#2134johlju merged 21 commits intodsccommunity:mainfrom
Get-SqlDscLogin: command to retrieve SQL Server logins#2134Conversation
|
Warning Rate limit exceeded@johlju has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 11 minutes and 0 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (2)
WalkthroughAdds a new public cmdlet Get-SqlDscLogin to retrieve SQL Server Logins via SMO (optional -Name and -Refresh). Adds localization for a missing-login message, unit and integration Pester tests, and inserts the integration test into the CI pipeline; updates CHANGELOG.md. Changes
Sequence Diagram(s)sequenceDiagram
actor User
participant Cmdlet as Get-SqlDscLogin
participant Server as SMO Server
participant Logins as Server.Logins
User->>Cmdlet: Invoke with -ServerObject [-Name] [-Refresh]
Cmdlet->>Logins: Refresh() (if -Refresh)
alt Name provided
Cmdlet->>Logins: Indexer[$Name]
alt Login found
Logins-->>Cmdlet: Login
Cmdlet-->>User: Login object
else Login missing
Cmdlet-->>User: Non-terminating error (GSDL0001) and $null (subject to ErrorAction)
end
else No name
Cmdlet->>Logins: Enumerate all logins
Logins-->>Cmdlet: Login[]
Cmdlet-->>User: Login[]
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes ✨ Finishing Touches🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 10
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these settings in your CodeRabbit configuration.
📒 Files selected for processing (6)
CHANGELOG.md(1 hunks)azure-pipelines.yml(1 hunks)source/Public/Get-SqlDscLogin.ps1(1 hunks)source/en-US/SqlServerDsc.strings.psd1(1 hunks)tests/Integration/Commands/Get-SqlDscLogin.Integration.Tests.ps1(1 hunks)tests/Unit/Public/Get-SqlDscLogin.Tests.ps1(1 hunks)
🧰 Additional context used
📓 Path-based instructions (15)
azure-pipelines.yml
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
Integration test script files for public commands must be added to a group within the 'Integration_Test_Commands_SqlServer' stage in ./azure-pipelines.yml.
Files:
azure-pipelines.yml
source/en-US/SqlServerDsc.strings.psd1
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
For public commands and private functions, all localized strings should be added in source/en-US/SqlServerDsc.strings.psd1, and localized string key names should be prefixed with the function name using underscores.
Files:
source/en-US/SqlServerDsc.strings.psd1
source/en-US/*.strings.psd1
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
For class-based resources, localized strings should be added in a separate file in source/en-US, named to exactly match the resource class name with the suffix .strings.psd1.
Files:
source/en-US/SqlServerDsc.strings.psd1
source/en-US/*.psd1
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
Localized string key names should use underscores as word separators if the key name has more than one word.
Files:
source/en-US/SqlServerDsc.strings.psd1
source/Public/*.ps1
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
source/Public/*.ps1: Public PowerShell commands should each have their own script file named after the command (with .ps1 extension) and be placed in the folder source/Public.
All public command names must have the noun prefixed with 'SqlDsc', e.g. {Verb}-SqlDsc{Noun}.
Files:
source/Public/Get-SqlDscLogin.ps1
source/{Public,Private,Classes}/*.ps1
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
source/{Public,Private,Classes}/*.ps1: Comment-based help should always be before the function-statement for each public command and private function, and before the class-statement for each class-based resource. It should be in the format of a comment block and at least use the keywords: .SYNOPSIS, .DESCRIPTION, .PARAMETER, .EXAMPLE, and .NOTES.
Each comment-based help keyword should be indented with 4 spaces and each keyword's text should be indented 8 spaces.
The text for keyword .DESCRIPTION should be descriptive and must have a length greater than 40 characters. The .SYNOPSIS keyword text should be a short description.
A comment-based help must have at least one example, but preferably more examples to showcase all possible parameter sets and different parameter combinations.
Use PascalCase for function names and parameters in public commands, private functions, and class-based resources.
Files:
source/Public/Get-SqlDscLogin.ps1
source/{Public,Private}/*.ps1
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
source/{Public,Private}/*.ps1: All message strings for Write-Debug, Write-Verbose, Write-Error, Write-Warning and other error messages in public commands and private functions should be localized using localized string keys.
All public command and private function names must follow the standard PowerShell Verb-Noun format.
All public command and private function names must use PowerShell approved verbs.
All public commands and private functions should always be advanced functions and have [CmdLetBinding()] attribute.
Public commands and private functions with no parameters should still have an empty parameter block param ().
Every parameter in public commands and private functions should include the [Parameter()] attribute.
A mandatory parameter in public commands and private functions should contain the decoration [Parameter(Mandatory = $true)], and non-mandatory parameters should not contain the Mandatory decoration.
Parameters attributes, datatype and its name should be on separate lines.
Parameters must be separated by a single, blank line.
Use Write-Verbose to output verbose output for actions a public command or private function does.
Use Write-Debug for debug output for processes within the script for user to see the decisions a command or private function does.
Files:
source/Public/Get-SqlDscLogin.ps1
**/*.ps1
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
**/*.ps1: All PowerShell files should use UTF8 without BOM.
All PowerShell files must end with a new line.
Try to limit PowerShell code lines to 120 characters.
Use 4 spaces for indentation in PowerShell files, never use tabs.
Use '#' for single line comments in PowerShell code.
Use comment-blocks for multiline comments with the format <# ... #> where the multiline text is indented 4 spaces.
Use descriptive, clear, and full names for all variables, parameters, and function names. All names must be more than 2 characters. No abbreviations should be used.
Use camelCase for local variable names in PowerShell.
Use Write-Error for error messages.
Use Write-Warning for warning messages.
Use Write-Information for informational messages.
Never use Write-Host.
Never use backtick as line continuation in code.
Use splatting for commands to reduce line length.
PowerShell reserved keywords should be in all lower case.
Single quotes should always be used to delimit string literals wherever possible. Double quoted string literals may only be used when string literals contain ($) expressions that need to be evaluated.
Hashtables properties should always be in PascalCase and be on a separate line.
When comparing a value to $null, $null should be on the left side of the comparison.
Files:
source/Public/Get-SqlDscLogin.ps1tests/Unit/Public/Get-SqlDscLogin.Tests.ps1tests/Integration/Commands/Get-SqlDscLogin.Integration.Tests.ps1
CHANGELOG.md
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
The Unreleased section in CHANGELOG.md should always be updated when making changes to the codebase, using the keepachangelog format and providing concrete release notes.
Files:
CHANGELOG.md
**/*.md
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
**/*.md: Markdown files should wrap lines after a word when a line exceeds 80 characters.
Use 2 spaces for indentation in Markdown files.
Files:
CHANGELOG.md
tests/**/*.ps1
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
tests/**/*.ps1: All tests should use the Pester framework and use Pester v5.0 syntax.
Parameter validation should never be tested.
Test code should never be added outside of the Describe block.
There should only be one Pester Describe block per test file, and the name of the Describe block should be the same as the name of the public command, private function, or class-based resource being tested.
Each scenario or code path being tested should have its own Pester Context block that starts with the phrase 'When'.
Pester It block descriptions should start with the phrase 'Should'.
It blocks must always call the command or function being tested and result and outcomes should be kept in the same It block.
BeforeAll and BeforeEach blocks should never call the command or function being tested.
BeforeAll, BeforeEach, AfterAll and AfterEach blocks should be used inside the Context block as near as possible to the It block that will use the test data, test setup and teardown.
AfterAll block can be used to clean up any test data.
BeforeEach and AfterEach blocks should be used sparingly.
It is okay to duplicate code in BeforeAll and BeforeEach blocks that are used inside different Context blocks.
Use localized strings in the tests only when necessary.
Files that need to be mocked should be created in Pester's test drive using the $TestDrive variable.
Files:
tests/Unit/Public/Get-SqlDscLogin.Tests.ps1tests/Integration/Commands/Get-SqlDscLogin.Integration.Tests.ps1
tests/Unit/{Classes,Public,Private}/*.Tests.ps1
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
Unit tests should be added for all public commands, private functions and class-based resources. Unit tests for class-based resources should be placed in tests/Unit/Classes, for public commands in tests/Unit/Public, and for private functions in tests/Unit/Private. The unit tests should be named after the item being tested with the suffix .Tests.ps1.
Files:
tests/Unit/Public/Get-SqlDscLogin.Tests.ps1
tests/Unit/Public/*.Tests.ps1
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
tests/Unit/Public/*.Tests.ps1: All public commands should always have a test to validate parameter sets using the provided template.
All public commands should also include tests to validate parameter properties.
Files:
tests/Unit/Public/Get-SqlDscLogin.Tests.ps1
tests/Unit/**/*.ps1
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
tests/Unit/**/*.ps1: Never test, mock or use Should -Invoke for Write-Verbose and Write-Debug.
Never use Should -Not -Throw in tests; instead, call the command directly.
All unit tests should use the provided code block prior to the Describe block to set up the test environment and load the correct module.
Files:
tests/Unit/Public/Get-SqlDscLogin.Tests.ps1
tests/Integration/Commands/*.Integration.Tests.ps1
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
tests/Integration/Commands/*.Integration.Tests.ps1: Integration tests for public commands should be placed in tests/Integration/Commands and named after the command with the suffix .Integration.Tests.ps1.
All integration tests must use the provided code block prior to the first Describe block to set up the integration test environment.
Files:
tests/Integration/Commands/Get-SqlDscLogin.Integration.Tests.ps1
🧠 Learnings (7)
📚 Learning: 2025-08-03T09:50:27.001Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-03T09:50:27.001Z
Learning: Applies to azure-pipelines.yml : Integration test script files for public commands must be added to a group within the 'Integration_Test_Commands_SqlServer' stage in ./azure-pipelines.yml.
Applied to files:
azure-pipelines.ymltests/Integration/Commands/Get-SqlDscLogin.Integration.Tests.ps1
📚 Learning: 2025-08-03T09:50:27.001Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-03T09:50:27.001Z
Learning: Applies to tests/Integration/Commands/*.Integration.Tests.ps1 : Integration tests for public commands should be placed in tests/Integration/Commands and named after the command with the suffix .Integration.Tests.ps1.
Applied to files:
azure-pipelines.ymltests/Integration/Commands/Get-SqlDscLogin.Integration.Tests.ps1
📚 Learning: 2025-08-03T09:50:27.001Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-03T09:50:27.001Z
Learning: Applies to tests/Unit/{Classes,Public,Private}/*.Tests.ps1 : Unit tests should be added for all public commands, private functions and class-based resources. Unit tests for class-based resources should be placed in tests/Unit/Classes, for public commands in tests/Unit/Public, and for private functions in tests/Unit/Private. The unit tests should be named after the item being tested with the suffix .Tests.ps1.
Applied to files:
azure-pipelines.ymltests/Unit/Public/Get-SqlDscLogin.Tests.ps1
📚 Learning: 2025-08-03T09:50:27.001Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-03T09:50:27.001Z
Learning: Applies to tests/Integration/Commands/*.Integration.Tests.ps1 : All integration tests must use the provided code block prior to the first Describe block to set up the integration test environment.
Applied to files:
azure-pipelines.ymltests/Integration/Commands/Get-SqlDscLogin.Integration.Tests.ps1
📚 Learning: 2025-08-03T09:50:27.001Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-03T09:50:27.001Z
Learning: Applies to source/en-US/SqlServerDsc.strings.psd1 : For public commands and private functions, all localized strings should be added in source/en-US/SqlServerDsc.strings.psd1, and localized string key names should be prefixed with the function name using underscores.
Applied to files:
source/en-US/SqlServerDsc.strings.psd1
📚 Learning: 2025-08-03T09:50:27.001Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-03T09:50:27.001Z
Learning: Applies to tests/Unit/Public/*.Tests.ps1 : All public commands should also include tests to validate parameter properties.
Applied to files:
tests/Unit/Public/Get-SqlDscLogin.Tests.ps1
📚 Learning: 2025-08-03T09:50:27.001Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-03T09:50:27.001Z
Learning: Applies to tests/Unit/Public/*.Tests.ps1 : All public commands should always have a test to validate parameter sets using the provided template.
Applied to files:
tests/Unit/Public/Get-SqlDscLogin.Tests.ps1
🧬 Code Graph Analysis (4)
source/Public/Get-SqlDscLogin.ps1 (1)
tests/Unit/Stubs/SMO.cs (3)
Login(354-484)Login(371-374)Login(376-379)
CHANGELOG.md (1)
tests/Unit/Stubs/SMO.cs (1)
Login(354-484)
tests/Unit/Public/Get-SqlDscLogin.Tests.ps1 (1)
tests/Unit/Stubs/SMO.cs (2)
Login(354-484)LoginType(29-39)
tests/Integration/Commands/Get-SqlDscLogin.Integration.Tests.ps1 (1)
tests/Unit/Stubs/SMO.cs (2)
Login(354-484)LoginType(29-39)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: dsccommunity.SqlServerDsc (Build Package Module)
- GitHub Check: PSScriptAnalyzer
- GitHub Check: PSScriptAnalyzer
🔇 Additional comments (7)
CHANGELOG.md (1)
18-24: LGTM: Unreleased entry clearly documents the new public command and behavior.The notes are concrete, follow Keep a Changelog structure, and mention -Refresh and name filtering.
azure-pipelines.yml (1)
252-252: LGTM: Integration test included in the SQL Server Commands stage.Get-SqlDscLogin.Integration.Tests.ps1 is correctly sequenced after Assert-SqlDscLogin, meeting the pipeline guideline.
tests/Unit/Public/Get-SqlDscLogin.Tests.ps1 (1)
93-96: Do not change the test — the localization key is stillLogin_Missing.Verified that the key remains named Login_Missing and no Login_Get_Missing exists, so the proposed test change is incorrect.
Files found:
- tests/Unit/Public/Get-SqlDscLogin.Tests.ps1 — line 94: $script:localizedData.Login_Missing
- source/Public/Get-SqlDscLogin.ps1 — line 67: $script:localizedData.Login_Missing
- source/en-US/SqlServerDsc.strings.psd1 — line 65: Login_Missing = There is no login with the name '{0}'.
Remove the suggested diff; keep the test as-is.
Likely an incorrect or invalid review comment.
tests/Integration/Commands/Get-SqlDscLogin.Integration.Tests.ps1 (4)
4-24: Integration test bootstrap block looks correctThe BeforeDiscovery block follows the DSC Community integration test pattern, ensures DscResource.Test is available, and fails fast with a helpful message. Good use of stream redirection and -ErrorAction Stop.
26-37: Solid test harness setupModule import and PSDefaultParameterValues setup are appropriate for Pester v5 and DscResource.Test. The stub module import is also correctly located.
39-46: Clean teardownClearing PSDefaultParameterValues and unloading the tested module prevents bleed-over to other tests.
48-48: Integration test file is included in the pipeline — no action requiredVerified that:
- tests/Integration/Commands/Get-SqlDscLogin.Integration.Tests.ps1 exists.
- azure-pipelines.yml contains the Integration_Test_Commands_SqlServer stage (around line 196) and references the test at line 252: 'tests/Integration/Commands/Get-SqlDscLogin.Integration.Tests.ps1'.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2134 +/- ##
====================================
Coverage 94% 94%
====================================
Files 107 108 +1
Lines 8094 8109 +15
====================================
+ Hits 7655 7670 +15
Misses 439 439
🚀 New features to boost your workflow:
|
…in integration tests
Get-SqlDscLogin: function to retrieve SQL Server loginsGet-SqlDscLogin: command to retrieve SQL Server logins
There was a problem hiding this comment.
Actionable comments posted: 4
♻️ Duplicate comments (5)
tests/Integration/Commands/Get-SqlDscLogin.Integration.Tests.ps1 (5)
53-53: Cast to array before indexing to handle single-item resultsIndexing
$result[0]can fail when only one item is returned (Windows PowerShell behavior). Cast first.Apply this diff:
- $result[0] | Should -BeOfType 'Microsoft.SqlServer.Management.Smo.Login' + @($result)[0] | Should -BeOfType 'Microsoft.SqlServer.Management.Smo.Login'
59-59: Make 'Contain sa' assertion robust for single-item resultWhen only a single login is returned,
$result.Nameis a string andShould -Containexpects a collection. Cast to array.Apply this diff:
- $result.Name | Should -Contain 'sa' + @($result).Name | Should -Contain 'sa'
72-75: Prefer single quotes for string literals and escape embedded quotesNo interpolation needed. Aligns with repo style guidelines.
Apply this diff:
- { Get-SqlDscLogin -ServerObject $script:serverObject -Name 'NonExistentLogin' -ErrorAction 'Stop' } | - Should -Throw -ExpectedMessage "There is no login with the name 'NonExistentLogin'." + { Get-SqlDscLogin -ServerObject $script:serverObject -Name 'NonExistentLogin' -ErrorAction 'Stop' } | + Should -Throw -ExpectedMessage 'There is no login with the name ''NonExistentLogin''.'
84-90: Cast to array before comparing Count to avoid scalar edge casesA single object has no Count in Windows PowerShell. Cast both sides.
Apply this diff:
- $resultWithoutRefresh.Count | Should -Be $resultWithRefresh.Count + @($resultWithoutRefresh).Count | Should -Be @($resultWithRefresh).Count
41-41: Prefer splatting for Connect-SqlDscDatabaseEngine to align with style and readabilityKeeps line length in check and eases future parameter additions.
Apply this diff:
- $script:serverObject = Connect-SqlDscDatabaseEngine -InstanceName $script:mockInstanceName -Credential $script:mockSqlAdminCredential + $connectParams = @{ + InstanceName = $script:mockInstanceName + Credential = $script:mockSqlAdminCredential + } + $script:serverObject = Connect-SqlDscDatabaseEngine @connectParams
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
tests/Integration/Commands/Get-SqlDscLogin.Integration.Tests.ps1(1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
tests/**/*.ps1
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
tests/**/*.ps1: All tests should use the Pester framework and use Pester v5.0 syntax.
Parameter validation should never be tested.
Test code should never be added outside of the Describe block.
There should only be one Pester Describe block per test file, and the name of the Describe block should be the same as the name of the public command, private function, or class-based resource being tested.
Each scenario or code path being tested should have its own Pester Context block that starts with the phrase 'When'.
Pester It block descriptions should start with the phrase 'Should'.
It blocks must always call the command or function being tested and result and outcomes should be kept in the same It block.
BeforeAll and BeforeEach blocks should never call the command or function being tested.
BeforeAll, BeforeEach, AfterAll and AfterEach blocks should be used inside the Context block as near as possible to the It block that will use the test data, test setup and teardown.
AfterAll block can be used to clean up any test data.
BeforeEach and AfterEach blocks should be used sparingly.
It is okay to duplicate code in BeforeAll and BeforeEach blocks that are used inside different Context blocks.
Use localized strings in the tests only when necessary.
Files that need to be mocked should be created in Pester's test drive using the $TestDrive variable.
Files:
tests/Integration/Commands/Get-SqlDscLogin.Integration.Tests.ps1
tests/Integration/Commands/*.Integration.Tests.ps1
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
tests/Integration/Commands/*.Integration.Tests.ps1: Integration tests for public commands should be placed in tests/Integration/Commands and named after the command with the suffix .Integration.Tests.ps1.
All integration tests must use the provided code block prior to the first Describe block to set up the integration test environment.
Files:
tests/Integration/Commands/Get-SqlDscLogin.Integration.Tests.ps1
**/*.ps1
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
**/*.ps1: All PowerShell files should use UTF8 without BOM.
All PowerShell files must end with a new line.
Try to limit PowerShell code lines to 120 characters.
Use 4 spaces for indentation in PowerShell files, never use tabs.
Use '#' for single line comments in PowerShell code.
Use comment-blocks for multiline comments with the format <# ... #> where the multiline text is indented 4 spaces.
Use descriptive, clear, and full names for all variables, parameters, and function names. All names must be more than 2 characters. No abbreviations should be used.
Use camelCase for local variable names in PowerShell.
Use Write-Error for error messages.
Use Write-Warning for warning messages.
Use Write-Information for informational messages.
Never use Write-Host.
Never use backtick as line continuation in code.
Use splatting for commands to reduce line length.
PowerShell reserved keywords should be in all lower case.
Single quotes should always be used to delimit string literals wherever possible. Double quoted string literals may only be used when string literals contain ($) expressions that need to be evaluated.
Hashtables properties should always be in PascalCase and be on a separate line.
When comparing a value to $null, $null should be on the left side of the comparison.
Files:
tests/Integration/Commands/Get-SqlDscLogin.Integration.Tests.ps1
🧠 Learnings (9)
📓 Common learnings
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-03T09:50:27.001Z
Learning: Applies to source/en-US/SqlServerDsc.strings.psd1 : For public commands and private functions, all localized strings should be added in source/en-US/SqlServerDsc.strings.psd1, and localized string key names should be prefixed with the function name using underscores.
📚 Learning: 2025-08-03T09:50:27.001Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-03T09:50:27.001Z
Learning: Applies to azure-pipelines.yml : Integration test script files for public commands must be added to a group within the 'Integration_Test_Commands_SqlServer' stage in ./azure-pipelines.yml.
Applied to files:
tests/Integration/Commands/Get-SqlDscLogin.Integration.Tests.ps1
📚 Learning: 2025-08-03T09:50:27.001Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-03T09:50:27.001Z
Learning: Applies to tests/Integration/Commands/*.Integration.Tests.ps1 : Integration tests for public commands should be placed in tests/Integration/Commands and named after the command with the suffix .Integration.Tests.ps1.
Applied to files:
tests/Integration/Commands/Get-SqlDscLogin.Integration.Tests.ps1
📚 Learning: 2025-08-03T09:50:27.001Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-03T09:50:27.001Z
Learning: Applies to tests/Integration/Commands/*.Integration.Tests.ps1 : All integration tests must use the provided code block prior to the first Describe block to set up the integration test environment.
Applied to files:
tests/Integration/Commands/Get-SqlDscLogin.Integration.Tests.ps1
📚 Learning: 2025-08-15T05:37:29.255Z
Learnt from: johlju
PR: dsccommunity/SqlServerDsc#2134
File: tests/Unit/Public/Get-SqlDscLogin.Tests.ps1:178-185
Timestamp: 2025-08-15T05:37:29.255Z
Learning: In PowerShell Pester tests, when piping an array to `Should -BeOfType`, PowerShell's pipeline automatically unrolls the array and checks the type of each individual element, not the array type itself. This means `$result | Should -BeOfType 'SomeType'` for an array will validate every element's type without needing the `-All` modifier.
Applied to files:
tests/Integration/Commands/Get-SqlDscLogin.Integration.Tests.ps1
📚 Learning: 2025-08-03T09:50:27.001Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-03T09:50:27.001Z
Learning: Applies to **/*.ps1 : Single quotes should always be used to delimit string literals wherever possible. Double quoted string literals may only be used when string literals contain ($) expressions that need to be evaluated.
Applied to files:
tests/Integration/Commands/Get-SqlDscLogin.Integration.Tests.ps1
📚 Learning: 2025-08-03T09:50:27.001Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-03T09:50:27.001Z
Learning: Applies to tests/Unit/**/*.ps1 : Never use Should -Not -Throw in tests; instead, call the command directly.
Applied to files:
tests/Integration/Commands/Get-SqlDscLogin.Integration.Tests.ps1
📚 Learning: 2025-08-03T09:50:27.001Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-03T09:50:27.001Z
Learning: Applies to tests/**/*.ps1 : Use localized strings in the tests only when necessary.
Applied to files:
tests/Integration/Commands/Get-SqlDscLogin.Integration.Tests.ps1
📚 Learning: 2025-08-03T09:50:27.001Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-03T09:50:27.001Z
Learning: Applies to tests/**/*.ps1 : Pester It block descriptions should start with the phrase 'Should'.
Applied to files:
tests/Integration/Commands/Get-SqlDscLogin.Integration.Tests.ps1
🧬 Code Graph Analysis (1)
tests/Integration/Commands/Get-SqlDscLogin.Integration.Tests.ps1 (1)
tests/Unit/Stubs/SMO.cs (2)
Login(354-484)LoginType(29-39)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: dsccommunity.SqlServerDsc (Build Package Module)
- GitHub Check: PSScriptAnalyzer
- GitHub Check: PSScriptAnalyzer
🔇 Additional comments (1)
tests/Integration/Commands/Get-SqlDscLogin.Integration.Tests.ps1 (1)
32-32: Integration test is wired into CI — no action requiredazure-pipelines.yml contains the Integration_Test_Commands_SqlServer stage and includes:
- tests/Integration/Commands/Get-SqlDscLogin.Integration.Tests.ps1 (pipeline entries around lines ~249–253; stage defined around line ~196)
…ntation for clarity
… Get-SqlDscLogin function
… for non-existent login
…sure proper handling of null results
…bles for consistency
There was a problem hiding this comment.
Actionable comments posted: 5
♻️ Duplicate comments (5)
source/en-US/SqlServerDsc.strings.psd1 (1)
64-66: Prefix the localization key with the function name (per guideline).Keys for public commands must be prefixed with the function name using underscores. Rename
Login_Get_MissingtoGet_SqlDscLogin_Login_Missingand update references in code and tests.Apply this diff here:
- ## Get-SqlDscLogin - Login_Get_Missing = There is no login with the name '{0}'. + ## Get-SqlDscLogin + Get_SqlDscLogin_Login_Missing = There is no login with the name '{0}'.Update usages in other files accordingly (see suggestions in those files' comments).
source/Public/Get-SqlDscLogin.ps1 (2)
66-75: Use ObjectNotFound for missing login and align to function-prefixed key.Category ‘ObjectNotFound’ better represents a missing object. Also, if you adopt the function-prefixed key per strings file, update the reference here.
- $missingLoginMessage = $script:localizedData.Login_Get_Missing -f $Name + $missingLoginMessage = $script:localizedData.Get_SqlDscLogin_Login_Missing -f $Name $writeErrorParameters = @{ Message = $missingLoginMessage - Category = 'InvalidOperation' + Category = 'ObjectNotFound' ErrorId = 'GSDL0001' # cspell: disable-line TargetObject = $Name }
14-20: Fix help grammar and wording.Minor copy edits improve clarity and match style (“number” for countables).
- .PARAMETER Refresh - Specifies that the **ServerObject**'s logins should be refreshed before - trying get the login object. This is helpful when logins could have been - modified outside of the **ServerObject**, for example through T-SQL. But - on instances with a large amount of logins it might be better to make - sure the **ServerObject** is recent enough. + .PARAMETER Refresh + Specifies that the **ServerObject**'s logins should be refreshed before + trying to get the login object. This is helpful when logins could have been + modified outside of the **ServerObject**, for example through T-SQL. On + instances with a large number of logins it might be better to make + sure the **ServerObject** is recent enough.tests/Integration/Commands/Get-SqlDscLogin.Integration.Tests.ps1 (2)
56-61: Make 'Contain sa' robust for single-item results.When only one login is returned,
$result.Nameis a string. Cast to array to keep behavior consistent across PS editions.- $result = Get-SqlDscLogin -ServerObject $script:serverObject - - $result.Name | Should -Contain 'sa' + $result = Get-SqlDscLogin -ServerObject $script:serverObject + @($result).Name | Should -Contain 'sa'
39-42: Optional: Use splatting for Connect-SqlDscDatabaseEngine to improve readability.Keeps line length in check and conforms with style guidance.
- $script:mockSqlAdminCredential = [System.Management.Automation.PSCredential]::new($script:mockSqlAdministratorUserName, $script:mockSqlAdministratorPassword) - - $script:serverObject = Connect-SqlDscDatabaseEngine -InstanceName $script:mockInstanceName -Credential $script:mockSqlAdminCredential + $script:mockSqlAdminCredential = [System.Management.Automation.PSCredential]::new($script:mockSqlAdministratorUserName, $script:mockSqlAdministratorPassword) + + $connectParams = @{ + InstanceName = $script:mockInstanceName + Credential = $script:mockSqlAdminCredential + } + $script:serverObject = Connect-SqlDscDatabaseEngine @connectParams
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (4)
source/Public/Get-SqlDscLogin.ps1(1 hunks)source/en-US/SqlServerDsc.strings.psd1(1 hunks)tests/Integration/Commands/Get-SqlDscLogin.Integration.Tests.ps1(1 hunks)tests/Unit/Public/Get-SqlDscLogin.Tests.ps1(1 hunks)
🧰 Additional context used
📓 Path-based instructions (12)
source/en-US/SqlServerDsc.strings.psd1
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
For public commands and private functions, all localized strings should be added in source/en-US/SqlServerDsc.strings.psd1, and localized string key names should be prefixed with the function name using underscores.
Files:
source/en-US/SqlServerDsc.strings.psd1
source/en-US/*.strings.psd1
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
For class-based resources, localized strings should be added in a separate file in source/en-US, named to exactly match the resource class name with the suffix .strings.psd1.
Files:
source/en-US/SqlServerDsc.strings.psd1
source/en-US/*.psd1
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
Localized string key names should use underscores as word separators if the key name has more than one word.
Files:
source/en-US/SqlServerDsc.strings.psd1
tests/**/*.ps1
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
tests/**/*.ps1: All tests should use the Pester framework and use Pester v5.0 syntax.
Parameter validation should never be tested.
Test code should never be added outside of the Describe block.
There should only be one Pester Describe block per test file, and the name of the Describe block should be the same as the name of the public command, private function, or class-based resource being tested.
Each scenario or code path being tested should have its own Pester Context block that starts with the phrase 'When'.
Pester It block descriptions should start with the phrase 'Should'.
It blocks must always call the command or function being tested and result and outcomes should be kept in the same It block.
BeforeAll and BeforeEach blocks should never call the command or function being tested.
BeforeAll, BeforeEach, AfterAll and AfterEach blocks should be used inside the Context block as near as possible to the It block that will use the test data, test setup and teardown.
AfterAll block can be used to clean up any test data.
BeforeEach and AfterEach blocks should be used sparingly.
It is okay to duplicate code in BeforeAll and BeforeEach blocks that are used inside different Context blocks.
Use localized strings in the tests only when necessary.
Files that need to be mocked should be created in Pester's test drive using the $TestDrive variable.
Files:
tests/Unit/Public/Get-SqlDscLogin.Tests.ps1tests/Integration/Commands/Get-SqlDscLogin.Integration.Tests.ps1
tests/Unit/{Classes,Public,Private}/*.Tests.ps1
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
Unit tests should be added for all public commands, private functions and class-based resources. Unit tests for class-based resources should be placed in tests/Unit/Classes, for public commands in tests/Unit/Public, and for private functions in tests/Unit/Private. The unit tests should be named after the item being tested with the suffix .Tests.ps1.
Files:
tests/Unit/Public/Get-SqlDscLogin.Tests.ps1
tests/Unit/Public/*.Tests.ps1
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
tests/Unit/Public/*.Tests.ps1: All public commands should always have a test to validate parameter sets using the provided template.
All public commands should also include tests to validate parameter properties.
Files:
tests/Unit/Public/Get-SqlDscLogin.Tests.ps1
tests/Unit/**/*.ps1
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
tests/Unit/**/*.ps1: Never test, mock or use Should -Invoke for Write-Verbose and Write-Debug.
Never use Should -Not -Throw in tests; instead, call the command directly.
All unit tests should use the provided code block prior to the Describe block to set up the test environment and load the correct module.
Files:
tests/Unit/Public/Get-SqlDscLogin.Tests.ps1
**/*.ps1
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
**/*.ps1: All PowerShell files should use UTF8 without BOM.
All PowerShell files must end with a new line.
Try to limit PowerShell code lines to 120 characters.
Use 4 spaces for indentation in PowerShell files, never use tabs.
Use '#' for single line comments in PowerShell code.
Use comment-blocks for multiline comments with the format <# ... #> where the multiline text is indented 4 spaces.
Use descriptive, clear, and full names for all variables, parameters, and function names. All names must be more than 2 characters. No abbreviations should be used.
Use camelCase for local variable names in PowerShell.
Use Write-Error for error messages.
Use Write-Warning for warning messages.
Use Write-Information for informational messages.
Never use Write-Host.
Never use backtick as line continuation in code.
Use splatting for commands to reduce line length.
PowerShell reserved keywords should be in all lower case.
Single quotes should always be used to delimit string literals wherever possible. Double quoted string literals may only be used when string literals contain ($) expressions that need to be evaluated.
Hashtables properties should always be in PascalCase and be on a separate line.
When comparing a value to $null, $null should be on the left side of the comparison.
Files:
tests/Unit/Public/Get-SqlDscLogin.Tests.ps1source/Public/Get-SqlDscLogin.ps1tests/Integration/Commands/Get-SqlDscLogin.Integration.Tests.ps1
source/Public/*.ps1
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
source/Public/*.ps1: Public PowerShell commands should each have their own script file named after the command (with .ps1 extension) and be placed in the folder source/Public.
All public command names must have the noun prefixed with 'SqlDsc', e.g. {Verb}-SqlDsc{Noun}.
Files:
source/Public/Get-SqlDscLogin.ps1
source/{Public,Private,Classes}/*.ps1
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
source/{Public,Private,Classes}/*.ps1: Comment-based help should always be before the function-statement for each public command and private function, and before the class-statement for each class-based resource. It should be in the format of a comment block and at least use the keywords: .SYNOPSIS, .DESCRIPTION, .PARAMETER, .EXAMPLE, and .NOTES.
Each comment-based help keyword should be indented with 4 spaces and each keyword's text should be indented 8 spaces.
The text for keyword .DESCRIPTION should be descriptive and must have a length greater than 40 characters. The .SYNOPSIS keyword text should be a short description.
A comment-based help must have at least one example, but preferably more examples to showcase all possible parameter sets and different parameter combinations.
Use PascalCase for function names and parameters in public commands, private functions, and class-based resources.
Files:
source/Public/Get-SqlDscLogin.ps1
source/{Public,Private}/*.ps1
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
source/{Public,Private}/*.ps1: All message strings for Write-Debug, Write-Verbose, Write-Error, Write-Warning and other error messages in public commands and private functions should be localized using localized string keys.
All public command and private function names must follow the standard PowerShell Verb-Noun format.
All public command and private function names must use PowerShell approved verbs.
All public commands and private functions should always be advanced functions and have [CmdLetBinding()] attribute.
Public commands and private functions with no parameters should still have an empty parameter block param ().
Every parameter in public commands and private functions should include the [Parameter()] attribute.
A mandatory parameter in public commands and private functions should contain the decoration [Parameter(Mandatory = $true)], and non-mandatory parameters should not contain the Mandatory decoration.
Parameters attributes, datatype and its name should be on separate lines.
Parameters must be separated by a single, blank line.
Use Write-Verbose to output verbose output for actions a public command or private function does.
Use Write-Debug for debug output for processes within the script for user to see the decisions a command or private function does.
Files:
source/Public/Get-SqlDscLogin.ps1
tests/Integration/Commands/*.Integration.Tests.ps1
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
tests/Integration/Commands/*.Integration.Tests.ps1: Integration tests for public commands should be placed in tests/Integration/Commands and named after the command with the suffix .Integration.Tests.ps1.
All integration tests must use the provided code block prior to the first Describe block to set up the integration test environment.
Files:
tests/Integration/Commands/Get-SqlDscLogin.Integration.Tests.ps1
🧠 Learnings (11)
📓 Common learnings
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-03T09:50:27.001Z
Learning: Applies to source/en-US/SqlServerDsc.strings.psd1 : For public commands and private functions, all localized strings should be added in source/en-US/SqlServerDsc.strings.psd1, and localized string key names should be prefixed with the function name using underscores.
📚 Learning: 2025-08-03T09:50:27.001Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-03T09:50:27.001Z
Learning: Applies to source/en-US/SqlServerDsc.strings.psd1 : For public commands and private functions, all localized strings should be added in source/en-US/SqlServerDsc.strings.psd1, and localized string key names should be prefixed with the function name using underscores.
Applied to files:
source/en-US/SqlServerDsc.strings.psd1tests/Integration/Commands/Get-SqlDscLogin.Integration.Tests.ps1
📚 Learning: 2025-08-03T09:50:27.001Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-03T09:50:27.001Z
Learning: Applies to tests/Unit/Public/*.Tests.ps1 : All public commands should also include tests to validate parameter properties.
Applied to files:
tests/Unit/Public/Get-SqlDscLogin.Tests.ps1
📚 Learning: 2025-08-03T09:50:27.001Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-03T09:50:27.001Z
Learning: Applies to tests/Unit/{Classes,Public,Private}/*.Tests.ps1 : Unit tests should be added for all public commands, private functions and class-based resources. Unit tests for class-based resources should be placed in tests/Unit/Classes, for public commands in tests/Unit/Public, and for private functions in tests/Unit/Private. The unit tests should be named after the item being tested with the suffix .Tests.ps1.
Applied to files:
tests/Unit/Public/Get-SqlDscLogin.Tests.ps1
📚 Learning: 2025-08-03T09:50:27.001Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-03T09:50:27.001Z
Learning: Applies to tests/Unit/Public/*.Tests.ps1 : All public commands should always have a test to validate parameter sets using the provided template.
Applied to files:
tests/Unit/Public/Get-SqlDscLogin.Tests.ps1
📚 Learning: 2025-08-15T05:37:29.255Z
Learnt from: johlju
PR: dsccommunity/SqlServerDsc#2134
File: tests/Unit/Public/Get-SqlDscLogin.Tests.ps1:178-185
Timestamp: 2025-08-15T05:37:29.255Z
Learning: In PowerShell Pester tests, when piping an array to `Should -BeOfType`, PowerShell's pipeline automatically unrolls the array and checks the type of each individual element, not the array type itself. This means `$result | Should -BeOfType 'SomeType'` for an array will validate every element's type without needing the `-All` modifier.
Applied to files:
tests/Unit/Public/Get-SqlDscLogin.Tests.ps1tests/Integration/Commands/Get-SqlDscLogin.Integration.Tests.ps1
📚 Learning: 2025-08-03T09:50:27.001Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-03T09:50:27.001Z
Learning: Applies to azure-pipelines.yml : Integration test script files for public commands must be added to a group within the 'Integration_Test_Commands_SqlServer' stage in ./azure-pipelines.yml.
Applied to files:
tests/Integration/Commands/Get-SqlDscLogin.Integration.Tests.ps1
📚 Learning: 2025-08-03T09:50:27.001Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-03T09:50:27.001Z
Learning: Applies to tests/Integration/Commands/*.Integration.Tests.ps1 : Integration tests for public commands should be placed in tests/Integration/Commands and named after the command with the suffix .Integration.Tests.ps1.
Applied to files:
tests/Integration/Commands/Get-SqlDscLogin.Integration.Tests.ps1
📚 Learning: 2025-08-03T09:50:27.001Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-03T09:50:27.001Z
Learning: Applies to tests/Integration/Commands/*.Integration.Tests.ps1 : All integration tests must use the provided code block prior to the first Describe block to set up the integration test environment.
Applied to files:
tests/Integration/Commands/Get-SqlDscLogin.Integration.Tests.ps1
📚 Learning: 2025-08-03T09:50:27.001Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-03T09:50:27.001Z
Learning: Applies to tests/**/*.ps1 : Files that need to be mocked should be created in Pester's test drive using the $TestDrive variable.
Applied to files:
tests/Integration/Commands/Get-SqlDscLogin.Integration.Tests.ps1
📚 Learning: 2025-08-03T09:50:27.001Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-03T09:50:27.001Z
Learning: Applies to source/en-US/*.psd1 : Localized string key names should use underscores as word separators if the key name has more than one word.
Applied to files:
tests/Integration/Commands/Get-SqlDscLogin.Integration.Tests.ps1
🧬 Code Graph Analysis (3)
tests/Unit/Public/Get-SqlDscLogin.Tests.ps1 (1)
tests/Unit/Stubs/SMO.cs (3)
Login(354-484)LoginType(29-39)Create(439-479)
source/Public/Get-SqlDscLogin.ps1 (1)
tests/Unit/Stubs/SMO.cs (1)
Login(354-484)
tests/Integration/Commands/Get-SqlDscLogin.Integration.Tests.ps1 (1)
tests/Unit/Stubs/SMO.cs (2)
Login(354-484)LoginType(29-39)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: dsccommunity.SqlServerDsc (Build Package Module)
- GitHub Check: PSScriptAnalyzer
- GitHub Check: PSScriptAnalyzer
🔇 Additional comments (1)
tests/Unit/Public/Get-SqlDscLogin.Tests.ps1 (1)
178-185: LGTM: Element type assertion is correct.Piping the array to Should -BeOfType asserts each element’s type (PowerShell pipeline unrolls arrays). Good coverage with count and names.
There was a problem hiding this comment.
Actionable comments posted: 2
♻️ Duplicate comments (5)
tests/Unit/Public/Get-SqlDscLogin.Tests.ps1 (1)
91-101: Prefix localized key with function name (per repo convention).Keys must be function-prefixed with underscores. Use Get_SqlDscLogin_Login_Missing instead of Login_Get_Missing, and update references accordingly.
Apply this diff in this file:
- $mockErrorMessage = InModuleScope -ScriptBlock { - $script:localizedData.Login_Get_Missing - } + $mockErrorMessage = InModuleScope -ScriptBlock { + $script:localizedData.Get_SqlDscLogin_Login_Missing + }Also update other references (shown in related comments):
- source/Public/Get-SqlDscLogin.ps1: replace
$script:localizedData.Login_Get_Missingwith$script:localizedData.Get_SqlDscLogin_Login_Missing.- source/en-US/SqlServerDsc.strings.psd1: rename/add
Get_SqlDscLogin_Login_Missing = There is no login with the name '{0}'.source/Public/Get-SqlDscLogin.ps1 (1)
15-19: Fix grammar and clarify Refresh help text (user-facing).“Tying get the login object” is grammatically incorrect. Also clarify guidance per earlier discussion.
Apply this diff:
- Specifies that the **ServerObject**'s logins should be refreshed before - trying get the login object. This is helpful when logins could have been - modified outside of the **ServerObject**, for example through T-SQL. But - on instances with a large amount of logins it might be better to make - sure the **ServerObject** is recent enough. + Specifies that the **ServerObject**'s logins should be refreshed before + trying to get the login object. This is helpful when logins may have been + modified outside of the **ServerObject**, for example through T-SQL. On + instances with a large number of logins, consider ensuring the **ServerObject** + is recent enough, or use **-Refresh**.tests/Integration/Commands/Get-SqlDscLogin.Integration.Tests.ps1 (3)
66-70: Make 'Contain sa' assertion robust for single-item results.When only one login is returned, $result.Name is a scalar string. Cast to array before accessing Name.
- $result.Name | Should -Contain 'sa' + @($result).Name | Should -Contain 'sa'
40-40: Nit: fix grammar in inline comment.- $mockSqlAdministratorUserName = 'SqlAdmin' # Using computer name as NetBIOS name throw exception. + $mockSqlAdministratorUserName = 'SqlAdmin' # Using the computer name as the NetBIOS name throws an exception.
45-45: Prefer splatting for Connect-SqlDscDatabaseEngine to align with style guidelines.Improves readability and line length.
- $script:serverObject = Connect-SqlDscDatabaseEngine -InstanceName $script:mockInstanceName -Credential $script:mockSqlAdminCredential + $connectParams = @{ + InstanceName = $script:mockInstanceName + Credential = $script:mockSqlAdminCredential + } + $script:serverObject = Connect-SqlDscDatabaseEngine @connectParams
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (3)
source/Public/Get-SqlDscLogin.ps1(1 hunks)tests/Integration/Commands/Get-SqlDscLogin.Integration.Tests.ps1(1 hunks)tests/Unit/Public/Get-SqlDscLogin.Tests.ps1(1 hunks)
🧰 Additional context used
📓 Path-based instructions (9)
source/Public/*.ps1
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
source/Public/*.ps1: Public PowerShell commands should each have their own script file named after the command (with .ps1 extension) and be placed in the folder source/Public.
All public command names must have the noun prefixed with 'SqlDsc', e.g. {Verb}-SqlDsc{Noun}.
Files:
source/Public/Get-SqlDscLogin.ps1
source/{Public,Private,Classes}/*.ps1
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
source/{Public,Private,Classes}/*.ps1: Comment-based help should always be before the function-statement for each public command and private function, and before the class-statement for each class-based resource. It should be in the format of a comment block and at least use the keywords: .SYNOPSIS, .DESCRIPTION, .PARAMETER, .EXAMPLE, and .NOTES.
Each comment-based help keyword should be indented with 4 spaces and each keyword's text should be indented 8 spaces.
The text for keyword .DESCRIPTION should be descriptive and must have a length greater than 40 characters. The .SYNOPSIS keyword text should be a short description.
A comment-based help must have at least one example, but preferably more examples to showcase all possible parameter sets and different parameter combinations.
Use PascalCase for function names and parameters in public commands, private functions, and class-based resources.
Files:
source/Public/Get-SqlDscLogin.ps1
source/{Public,Private}/*.ps1
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
source/{Public,Private}/*.ps1: All message strings for Write-Debug, Write-Verbose, Write-Error, Write-Warning and other error messages in public commands and private functions should be localized using localized string keys.
All public command and private function names must follow the standard PowerShell Verb-Noun format.
All public command and private function names must use PowerShell approved verbs.
All public commands and private functions should always be advanced functions and have [CmdLetBinding()] attribute.
Public commands and private functions with no parameters should still have an empty parameter block param ().
Every parameter in public commands and private functions should include the [Parameter()] attribute.
A mandatory parameter in public commands and private functions should contain the decoration [Parameter(Mandatory = $true)], and non-mandatory parameters should not contain the Mandatory decoration.
Parameters attributes, datatype and its name should be on separate lines.
Parameters must be separated by a single, blank line.
Use Write-Verbose to output verbose output for actions a public command or private function does.
Use Write-Debug for debug output for processes within the script for user to see the decisions a command or private function does.
Files:
source/Public/Get-SqlDscLogin.ps1
**/*.ps1
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
**/*.ps1: All PowerShell files should use UTF8 without BOM.
All PowerShell files must end with a new line.
Try to limit PowerShell code lines to 120 characters.
Use 4 spaces for indentation in PowerShell files, never use tabs.
Use '#' for single line comments in PowerShell code.
Use comment-blocks for multiline comments with the format <# ... #> where the multiline text is indented 4 spaces.
Use descriptive, clear, and full names for all variables, parameters, and function names. All names must be more than 2 characters. No abbreviations should be used.
Use camelCase for local variable names in PowerShell.
Use Write-Error for error messages.
Use Write-Warning for warning messages.
Use Write-Information for informational messages.
Never use Write-Host.
Never use backtick as line continuation in code.
Use splatting for commands to reduce line length.
PowerShell reserved keywords should be in all lower case.
Single quotes should always be used to delimit string literals wherever possible. Double quoted string literals may only be used when string literals contain ($) expressions that need to be evaluated.
Hashtables properties should always be in PascalCase and be on a separate line.
When comparing a value to $null, $null should be on the left side of the comparison.
Files:
source/Public/Get-SqlDscLogin.ps1tests/Unit/Public/Get-SqlDscLogin.Tests.ps1tests/Integration/Commands/Get-SqlDscLogin.Integration.Tests.ps1
tests/**/*.ps1
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
tests/**/*.ps1: All tests should use the Pester framework and use Pester v5.0 syntax.
Parameter validation should never be tested.
Test code should never be added outside of the Describe block.
There should only be one Pester Describe block per test file, and the name of the Describe block should be the same as the name of the public command, private function, or class-based resource being tested.
Each scenario or code path being tested should have its own Pester Context block that starts with the phrase 'When'.
Pester It block descriptions should start with the phrase 'Should'.
It blocks must always call the command or function being tested and result and outcomes should be kept in the same It block.
BeforeAll and BeforeEach blocks should never call the command or function being tested.
BeforeAll, BeforeEach, AfterAll and AfterEach blocks should be used inside the Context block as near as possible to the It block that will use the test data, test setup and teardown.
AfterAll block can be used to clean up any test data.
BeforeEach and AfterEach blocks should be used sparingly.
It is okay to duplicate code in BeforeAll and BeforeEach blocks that are used inside different Context blocks.
Use localized strings in the tests only when necessary.
Files that need to be mocked should be created in Pester's test drive using the $TestDrive variable.
Files:
tests/Unit/Public/Get-SqlDscLogin.Tests.ps1tests/Integration/Commands/Get-SqlDscLogin.Integration.Tests.ps1
tests/Unit/{Classes,Public,Private}/*.Tests.ps1
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
Unit tests should be added for all public commands, private functions and class-based resources. Unit tests for class-based resources should be placed in tests/Unit/Classes, for public commands in tests/Unit/Public, and for private functions in tests/Unit/Private. The unit tests should be named after the item being tested with the suffix .Tests.ps1.
Files:
tests/Unit/Public/Get-SqlDscLogin.Tests.ps1
tests/Unit/Public/*.Tests.ps1
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
tests/Unit/Public/*.Tests.ps1: All public commands should always have a test to validate parameter sets using the provided template.
All public commands should also include tests to validate parameter properties.
Files:
tests/Unit/Public/Get-SqlDscLogin.Tests.ps1
tests/Unit/**/*.ps1
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
tests/Unit/**/*.ps1: Never test, mock or use Should -Invoke for Write-Verbose and Write-Debug.
Never use Should -Not -Throw in tests; instead, call the command directly.
All unit tests should use the provided code block prior to the Describe block to set up the test environment and load the correct module.
Files:
tests/Unit/Public/Get-SqlDscLogin.Tests.ps1
tests/Integration/Commands/*.Integration.Tests.ps1
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
tests/Integration/Commands/*.Integration.Tests.ps1: Integration tests for public commands should be placed in tests/Integration/Commands and named after the command with the suffix .Integration.Tests.ps1.
All integration tests must use the provided code block prior to the first Describe block to set up the integration test environment.
Files:
tests/Integration/Commands/Get-SqlDscLogin.Integration.Tests.ps1
🧠 Learnings (13)
📓 Common learnings
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-03T09:50:27.001Z
Learning: Applies to source/en-US/SqlServerDsc.strings.psd1 : For public commands and private functions, all localized strings should be added in source/en-US/SqlServerDsc.strings.psd1, and localized string key names should be prefixed with the function name using underscores.
📚 Learning: 2025-08-03T09:50:27.001Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-03T09:50:27.001Z
Learning: Applies to tests/Unit/{Classes,Public,Private}/*.Tests.ps1 : Unit tests should be added for all public commands, private functions and class-based resources. Unit tests for class-based resources should be placed in tests/Unit/Classes, for public commands in tests/Unit/Public, and for private functions in tests/Unit/Private. The unit tests should be named after the item being tested with the suffix .Tests.ps1.
Applied to files:
tests/Unit/Public/Get-SqlDscLogin.Tests.ps1
📚 Learning: 2025-08-03T09:50:27.001Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-03T09:50:27.001Z
Learning: Applies to tests/Unit/Public/*.Tests.ps1 : All public commands should also include tests to validate parameter properties.
Applied to files:
tests/Unit/Public/Get-SqlDscLogin.Tests.ps1
📚 Learning: 2025-08-03T09:50:27.001Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-03T09:50:27.001Z
Learning: Applies to tests/Unit/Public/*.Tests.ps1 : All public commands should always have a test to validate parameter sets using the provided template.
Applied to files:
tests/Unit/Public/Get-SqlDscLogin.Tests.ps1
📚 Learning: 2025-08-15T05:37:29.255Z
Learnt from: johlju
PR: dsccommunity/SqlServerDsc#2134
File: tests/Unit/Public/Get-SqlDscLogin.Tests.ps1:178-185
Timestamp: 2025-08-15T05:37:29.255Z
Learning: In PowerShell Pester tests, when piping an array to `Should -BeOfType`, PowerShell's pipeline automatically unrolls the array and checks the type of each individual element, not the array type itself. This means `$result | Should -BeOfType 'SomeType'` for an array will validate every element's type without needing the `-All` modifier.
Applied to files:
tests/Unit/Public/Get-SqlDscLogin.Tests.ps1tests/Integration/Commands/Get-SqlDscLogin.Integration.Tests.ps1
📚 Learning: 2025-08-03T09:50:27.001Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-03T09:50:27.001Z
Learning: Applies to tests/**/*.ps1 : Each scenario or code path being tested should have its own Pester Context block that starts with the phrase 'When'.
Applied to files:
tests/Unit/Public/Get-SqlDscLogin.Tests.ps1
📚 Learning: 2025-08-03T09:50:27.001Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-03T09:50:27.001Z
Learning: Applies to tests/**/*.ps1 : Use localized strings in the tests only when necessary.
Applied to files:
tests/Unit/Public/Get-SqlDscLogin.Tests.ps1
📚 Learning: 2025-08-03T09:50:27.001Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-03T09:50:27.001Z
Learning: Applies to azure-pipelines.yml : Integration test script files for public commands must be added to a group within the 'Integration_Test_Commands_SqlServer' stage in ./azure-pipelines.yml.
Applied to files:
tests/Integration/Commands/Get-SqlDscLogin.Integration.Tests.ps1
📚 Learning: 2025-08-03T09:50:27.001Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-03T09:50:27.001Z
Learning: Applies to tests/Integration/Commands/*.Integration.Tests.ps1 : Integration tests for public commands should be placed in tests/Integration/Commands and named after the command with the suffix .Integration.Tests.ps1.
Applied to files:
tests/Integration/Commands/Get-SqlDscLogin.Integration.Tests.ps1
📚 Learning: 2025-08-03T09:50:27.001Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-03T09:50:27.001Z
Learning: Applies to tests/Integration/Commands/*.Integration.Tests.ps1 : All integration tests must use the provided code block prior to the first Describe block to set up the integration test environment.
Applied to files:
tests/Integration/Commands/Get-SqlDscLogin.Integration.Tests.ps1
📚 Learning: 2025-08-03T09:50:27.001Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-03T09:50:27.001Z
Learning: Applies to tests/**/*.ps1 : Files that need to be mocked should be created in Pester's test drive using the $TestDrive variable.
Applied to files:
tests/Integration/Commands/Get-SqlDscLogin.Integration.Tests.ps1
📚 Learning: 2025-08-03T09:50:27.001Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-03T09:50:27.001Z
Learning: Applies to source/en-US/SqlServerDsc.strings.psd1 : For public commands and private functions, all localized strings should be added in source/en-US/SqlServerDsc.strings.psd1, and localized string key names should be prefixed with the function name using underscores.
Applied to files:
tests/Integration/Commands/Get-SqlDscLogin.Integration.Tests.ps1
📚 Learning: 2025-08-03T09:50:27.001Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-03T09:50:27.001Z
Learning: Applies to source/en-US/*.psd1 : Localized string key names should use underscores as word separators if the key name has more than one word.
Applied to files:
tests/Integration/Commands/Get-SqlDscLogin.Integration.Tests.ps1
🧬 Code Graph Analysis (3)
source/Public/Get-SqlDscLogin.ps1 (1)
tests/Unit/Stubs/SMO.cs (1)
Login(354-484)
tests/Unit/Public/Get-SqlDscLogin.Tests.ps1 (1)
tests/Unit/Stubs/SMO.cs (2)
Login(354-484)LoginType(29-39)
tests/Integration/Commands/Get-SqlDscLogin.Integration.Tests.ps1 (1)
tests/Unit/Stubs/SMO.cs (2)
Login(354-484)LoginType(29-39)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: dsccommunity.SqlServerDsc (Build Package Module)
- GitHub Check: PSScriptAnalyzer
- GitHub Check: PSScriptAnalyzer
There was a problem hiding this comment.
Actionable comments posted: 4
♻️ Duplicate comments (2)
tests/Unit/Public/Get-SqlDscLogin.Tests.ps1 (1)
110-112: Prefix localized key with function name to follow repository conventionsPer repo guidance, public command localized keys should be function-prefixed. Update the test to use the prefixed key.
- $mockErrorMessage = InModuleScope -ScriptBlock { - $script:localizedData.Login_Get_Missing - } + $mockErrorMessage = InModuleScope -ScriptBlock { + $script:localizedData.Get_SqlDscLogin_Login_Missing + }Note: Ensure source/en-US/SqlServerDsc.strings.psd1 defines Get_SqlDscLogin_Login_Missing and the command code references the same key.
source/Public/Get-SqlDscLogin.ps1 (1)
75-85: Prefix the localized key with the function name to comply with localization conventionsUpdate the localization key to be function-scoped, consistent with repo standards, and keep the ObjectNotFound category.
- $missingLoginMessage = $script:localizedData.Login_Get_Missing -f $Name + $missingLoginMessage = $script:localizedData.Get_SqlDscLogin_Login_Missing -f $NameAdditionally, ensure source/en-US/SqlServerDsc.strings.psd1 contains:
Get_SqlDscLogin_Login_Missing = 'There is no login with the name ''{0}''.'And update tests accordingly (tests/Unit/Public/Get-SqlDscLogin.Tests.ps1).
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (2)
source/Public/Get-SqlDscLogin.ps1(1 hunks)tests/Unit/Public/Get-SqlDscLogin.Tests.ps1(1 hunks)
🧰 Additional context used
📓 Path-based instructions (8)
tests/**/*.ps1
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
tests/**/*.ps1: All tests should use the Pester framework and use Pester v5.0 syntax.
Parameter validation should never be tested.
Test code should never be added outside of the Describe block.
There should only be one Pester Describe block per test file, and the name of the Describe block should be the same as the name of the public command, private function, or class-based resource being tested.
Each scenario or code path being tested should have its own Pester Context block that starts with the phrase 'When'.
Pester It block descriptions should start with the phrase 'Should'.
It blocks must always call the command or function being tested and result and outcomes should be kept in the same It block.
BeforeAll and BeforeEach blocks should never call the command or function being tested.
BeforeAll, BeforeEach, AfterAll and AfterEach blocks should be used inside the Context block as near as possible to the It block that will use the test data, test setup and teardown.
AfterAll block can be used to clean up any test data.
BeforeEach and AfterEach blocks should be used sparingly.
It is okay to duplicate code in BeforeAll and BeforeEach blocks that are used inside different Context blocks.
Use localized strings in the tests only when necessary.
Files that need to be mocked should be created in Pester's test drive using the $TestDrive variable.
Files:
tests/Unit/Public/Get-SqlDscLogin.Tests.ps1
tests/Unit/{Classes,Public,Private}/*.Tests.ps1
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
Unit tests should be added for all public commands, private functions and class-based resources. Unit tests for class-based resources should be placed in tests/Unit/Classes, for public commands in tests/Unit/Public, and for private functions in tests/Unit/Private. The unit tests should be named after the item being tested with the suffix .Tests.ps1.
Files:
tests/Unit/Public/Get-SqlDscLogin.Tests.ps1
tests/Unit/Public/*.Tests.ps1
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
tests/Unit/Public/*.Tests.ps1: All public commands should always have a test to validate parameter sets using the provided template.
All public commands should also include tests to validate parameter properties.
Files:
tests/Unit/Public/Get-SqlDscLogin.Tests.ps1
tests/Unit/**/*.ps1
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
tests/Unit/**/*.ps1: Never test, mock or use Should -Invoke for Write-Verbose and Write-Debug.
Never use Should -Not -Throw in tests; instead, call the command directly.
All unit tests should use the provided code block prior to the Describe block to set up the test environment and load the correct module.
Files:
tests/Unit/Public/Get-SqlDscLogin.Tests.ps1
**/*.ps1
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
**/*.ps1: All PowerShell files should use UTF8 without BOM.
All PowerShell files must end with a new line.
Try to limit PowerShell code lines to 120 characters.
Use 4 spaces for indentation in PowerShell files, never use tabs.
Use '#' for single line comments in PowerShell code.
Use comment-blocks for multiline comments with the format <# ... #> where the multiline text is indented 4 spaces.
Use descriptive, clear, and full names for all variables, parameters, and function names. All names must be more than 2 characters. No abbreviations should be used.
Use camelCase for local variable names in PowerShell.
Use Write-Error for error messages.
Use Write-Warning for warning messages.
Use Write-Information for informational messages.
Never use Write-Host.
Never use backtick as line continuation in code.
Use splatting for commands to reduce line length.
PowerShell reserved keywords should be in all lower case.
Single quotes should always be used to delimit string literals wherever possible. Double quoted string literals may only be used when string literals contain ($) expressions that need to be evaluated.
Hashtables properties should always be in PascalCase and be on a separate line.
When comparing a value to $null, $null should be on the left side of the comparison.
Files:
tests/Unit/Public/Get-SqlDscLogin.Tests.ps1source/Public/Get-SqlDscLogin.ps1
source/Public/*.ps1
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
source/Public/*.ps1: Public PowerShell commands should each have their own script file named after the command (with .ps1 extension) and be placed in the folder source/Public.
All public command names must have the noun prefixed with 'SqlDsc', e.g. {Verb}-SqlDsc{Noun}.
Files:
source/Public/Get-SqlDscLogin.ps1
source/{Public,Private,Classes}/*.ps1
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
source/{Public,Private,Classes}/*.ps1: Comment-based help should always be before the function-statement for each public command and private function, and before the class-statement for each class-based resource. It should be in the format of a comment block and at least use the keywords: .SYNOPSIS, .DESCRIPTION, .PARAMETER, .EXAMPLE, and .NOTES.
Each comment-based help keyword should be indented with 4 spaces and each keyword's text should be indented 8 spaces.
The text for keyword .DESCRIPTION should be descriptive and must have a length greater than 40 characters. The .SYNOPSIS keyword text should be a short description.
A comment-based help must have at least one example, but preferably more examples to showcase all possible parameter sets and different parameter combinations.
Use PascalCase for function names and parameters in public commands, private functions, and class-based resources.
Files:
source/Public/Get-SqlDscLogin.ps1
source/{Public,Private}/*.ps1
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
source/{Public,Private}/*.ps1: All message strings for Write-Debug, Write-Verbose, Write-Error, Write-Warning and other error messages in public commands and private functions should be localized using localized string keys.
All public command and private function names must follow the standard PowerShell Verb-Noun format.
All public command and private function names must use PowerShell approved verbs.
All public commands and private functions should always be advanced functions and have [CmdLetBinding()] attribute.
Public commands and private functions with no parameters should still have an empty parameter block param ().
Every parameter in public commands and private functions should include the [Parameter()] attribute.
A mandatory parameter in public commands and private functions should contain the decoration [Parameter(Mandatory = $true)], and non-mandatory parameters should not contain the Mandatory decoration.
Parameters attributes, datatype and its name should be on separate lines.
Parameters must be separated by a single, blank line.
Use Write-Verbose to output verbose output for actions a public command or private function does.
Use Write-Debug for debug output for processes within the script for user to see the decisions a command or private function does.
Files:
source/Public/Get-SqlDscLogin.ps1
🧠 Learnings (8)
📓 Common learnings
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-03T09:50:27.001Z
Learning: Applies to source/en-US/SqlServerDsc.strings.psd1 : For public commands and private functions, all localized strings should be added in source/en-US/SqlServerDsc.strings.psd1, and localized string key names should be prefixed with the function name using underscores.
📚 Learning: 2025-08-03T09:50:27.001Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-03T09:50:27.001Z
Learning: Applies to tests/Unit/{Classes,Public,Private}/*.Tests.ps1 : Unit tests should be added for all public commands, private functions and class-based resources. Unit tests for class-based resources should be placed in tests/Unit/Classes, for public commands in tests/Unit/Public, and for private functions in tests/Unit/Private. The unit tests should be named after the item being tested with the suffix .Tests.ps1.
Applied to files:
tests/Unit/Public/Get-SqlDscLogin.Tests.ps1
📚 Learning: 2025-08-03T09:50:27.001Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-03T09:50:27.001Z
Learning: Applies to tests/Unit/Public/*.Tests.ps1 : All public commands should also include tests to validate parameter properties.
Applied to files:
tests/Unit/Public/Get-SqlDscLogin.Tests.ps1
📚 Learning: 2025-08-03T09:50:27.001Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-03T09:50:27.001Z
Learning: Applies to tests/Unit/Public/*.Tests.ps1 : All public commands should always have a test to validate parameter sets using the provided template.
Applied to files:
tests/Unit/Public/Get-SqlDscLogin.Tests.ps1
📚 Learning: 2025-08-15T05:37:29.255Z
Learnt from: johlju
PR: dsccommunity/SqlServerDsc#2134
File: tests/Unit/Public/Get-SqlDscLogin.Tests.ps1:178-185
Timestamp: 2025-08-15T05:37:29.255Z
Learning: In PowerShell Pester tests, when piping an array to `Should -BeOfType`, PowerShell's pipeline automatically unrolls the array and checks the type of each individual element, not the array type itself. This means `$result | Should -BeOfType 'SomeType'` for an array will validate every element's type without needing the `-All` modifier.
Applied to files:
tests/Unit/Public/Get-SqlDscLogin.Tests.ps1
📚 Learning: 2025-08-03T09:50:27.001Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-03T09:50:27.001Z
Learning: Applies to tests/**/*.ps1 : Each scenario or code path being tested should have its own Pester Context block that starts with the phrase 'When'.
Applied to files:
tests/Unit/Public/Get-SqlDscLogin.Tests.ps1
📚 Learning: 2025-08-03T09:50:27.001Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-03T09:50:27.001Z
Learning: Applies to tests/**/*.ps1 : Use localized strings in the tests only when necessary.
Applied to files:
tests/Unit/Public/Get-SqlDscLogin.Tests.ps1
📚 Learning: 2025-08-03T09:50:27.001Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-03T09:50:27.001Z
Learning: Applies to source/{Public,Private}/*.ps1 : Every parameter in public commands and private functions should include the [Parameter()] attribute.
Applied to files:
tests/Unit/Public/Get-SqlDscLogin.Tests.ps1
🧬 Code Graph Analysis (2)
tests/Unit/Public/Get-SqlDscLogin.Tests.ps1 (1)
tests/Unit/Stubs/SMO.cs (3)
Login(354-484)LoginType(29-39)Create(439-479)
source/Public/Get-SqlDscLogin.ps1 (1)
tests/Unit/Stubs/SMO.cs (1)
Login(354-484)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: dsccommunity.SqlServerDsc (Build Package Module)
- GitHub Check: PSScriptAnalyzer
- GitHub Check: PSScriptAnalyzer
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Actionable comments posted: 5
♻️ Duplicate comments (2)
source/Public/Get-SqlDscLogin.ps1 (2)
75-75: Prefix localization key with the function name to follow repo conventionLocalization keys should be prefixed with the function name using underscores (per repo convention and learnings). Rename the key to Get_SqlDscLogin_Login_Missing and update the strings file and tests accordingly.
- $missingLoginMessage = $script:localizedData.Login_Get_Missing -f $Name + $missingLoginMessage = $script:localizedData.Get_SqlDscLogin_Login_Missing -f $NameRun this script to verify the key is defined and update test references:
#!/bin/bash set -euo pipefail echo "== Search for localization key definitions ==" rg -n --hidden "Get_SqlDscLogin_Login_Missing|Login_Get_Missing" -C2 echo echo "== Check tests for old key usage ==" rg -n --hidden "Login_Get_Missing" -C2 || true
27-38: Consolidate .OUTPUTS: the cmdlet returns Login[] (array) in all successful casesThe implementation casts the result to
[Microsoft.SqlServer.Management.Smo.Login[]], so help should reflect that. Also, avoid backticks around types in comment-based help.- .OUTPUTS - `[Microsoft.SqlServer.Management.Smo.Login]` - - Returns a single Login object when the Name parameter is specified and a - match is found. - - .OUTPUTS - `[Microsoft.SqlServer.Management.Smo.Login[]]` - - Returns an array of Login objects when the Name parameter is not specified - (returns all logins) or when multiple matches are found. + .OUTPUTS + Microsoft.SqlServer.Management.Smo.Login[] + + Returns an array of Login objects. When the Name parameter is specified + and a match is found, the array contains a single item. When Name is not + specified, the array contains all logins.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
source/Public/Get-SqlDscLogin.ps1(1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
source/Public/*.ps1
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
source/Public/*.ps1: Public PowerShell commands should each have their own script file named after the command (with .ps1 extension) and be placed in the folder source/Public.
All public command names must have the noun prefixed with 'SqlDsc', e.g. {Verb}-SqlDsc{Noun}.
Files:
source/Public/Get-SqlDscLogin.ps1
source/{Public,Private,Classes}/*.ps1
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
source/{Public,Private,Classes}/*.ps1: Comment-based help should always be before the function-statement for each public command and private function, and before the class-statement for each class-based resource. It should be in the format of a comment block and at least use the keywords: .SYNOPSIS, .DESCRIPTION, .PARAMETER, .EXAMPLE, and .NOTES.
Each comment-based help keyword should be indented with 4 spaces and each keyword's text should be indented 8 spaces.
The text for keyword .DESCRIPTION should be descriptive and must have a length greater than 40 characters. The .SYNOPSIS keyword text should be a short description.
A comment-based help must have at least one example, but preferably more examples to showcase all possible parameter sets and different parameter combinations.
Use PascalCase for function names and parameters in public commands, private functions, and class-based resources.
Files:
source/Public/Get-SqlDscLogin.ps1
source/{Public,Private}/*.ps1
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
source/{Public,Private}/*.ps1: All message strings for Write-Debug, Write-Verbose, Write-Error, Write-Warning and other error messages in public commands and private functions should be localized using localized string keys.
All public command and private function names must follow the standard PowerShell Verb-Noun format.
All public command and private function names must use PowerShell approved verbs.
All public commands and private functions should always be advanced functions and have [CmdLetBinding()] attribute.
Public commands and private functions with no parameters should still have an empty parameter block param ().
Every parameter in public commands and private functions should include the [Parameter()] attribute.
A mandatory parameter in public commands and private functions should contain the decoration [Parameter(Mandatory = $true)], and non-mandatory parameters should not contain the Mandatory decoration.
Parameters attributes, datatype and its name should be on separate lines.
Parameters must be separated by a single, blank line.
Use Write-Verbose to output verbose output for actions a public command or private function does.
Use Write-Debug for debug output for processes within the script for user to see the decisions a command or private function does.
Files:
source/Public/Get-SqlDscLogin.ps1
**/*.ps1
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
**/*.ps1: All PowerShell files should use UTF8 without BOM.
All PowerShell files must end with a new line.
Try to limit PowerShell code lines to 120 characters.
Use 4 spaces for indentation in PowerShell files, never use tabs.
Use '#' for single line comments in PowerShell code.
Use comment-blocks for multiline comments with the format <# ... #> where the multiline text is indented 4 spaces.
Use descriptive, clear, and full names for all variables, parameters, and function names. All names must be more than 2 characters. No abbreviations should be used.
Use camelCase for local variable names in PowerShell.
Use Write-Error for error messages.
Use Write-Warning for warning messages.
Use Write-Information for informational messages.
Never use Write-Host.
Never use backtick as line continuation in code.
Use splatting for commands to reduce line length.
PowerShell reserved keywords should be in all lower case.
Single quotes should always be used to delimit string literals wherever possible. Double quoted string literals may only be used when string literals contain ($) expressions that need to be evaluated.
Hashtables properties should always be in PascalCase and be on a separate line.
When comparing a value to $null, $null should be on the left side of the comparison.
Files:
source/Public/Get-SqlDscLogin.ps1
🧠 Learnings (1)
📓 Common learnings
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-03T09:50:27.001Z
Learning: Applies to source/en-US/SqlServerDsc.strings.psd1 : For public commands and private functions, all localized strings should be added in source/en-US/SqlServerDsc.strings.psd1, and localized string key names should be prefixed with the function name using underscores.
🧬 Code Graph Analysis (1)
source/Public/Get-SqlDscLogin.ps1 (1)
tests/Unit/Stubs/SMO.cs (1)
Login(354-484)
⏰ 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). (2)
- GitHub Check: dsccommunity.SqlServerDsc (Build Package Module)
- GitHub Check: PSScriptAnalyzer
🔇 Additional comments (2)
source/Public/Get-SqlDscLogin.ps1 (2)
77-81: Good choice of error Category: ObjectNotFoundThis accurately reflects the missing-login condition.
41-43: Attributes LGTM (advanced function + OutputType[])CmdletBinding and OutputType([Login[]]) align with implementation.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
johlju
left a comment
There was a problem hiding this comment.
Reviewed 2 of 6 files at r1, 1 of 3 files at r7, 1 of 2 files at r8, 2 of 2 files at r10, all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @johlju)
Pull Request (PR) description
Get-SqlDscLoginMicrosoft.SqlServer.Management.Smo.Loginobject that representsthe login.
-Refreshparameter to refresh the server's login collectionbefore retrieval.
This Pull Request (PR) fixes the following issues
None.
Task list
file CHANGELOG.md. Entry should say what was changed and how that
affects users (if applicable), and reference the issue being resolved
(if applicable).
This change is