Repository navigation
Set-DbaLogin - Read only the logins of -Login from the instance - #10809
Merged
Merged
Conversation
For -SqlInstance, the command called Get-DbaLogin without -Login and picked the logins of -Login out of the result afterwards. Get-DbaLogin processes every login it returns, so changing one login read all logins of the instance, which takes long on an instance with many logins or one far away. Sync-DbaLoginPassword calls it once per login and destination, so a sync of one login did the same. The call now passes -Login; the filter after it stays for the system logins. The new context changes one of two new logins with -Verbose and checks the messages Get-DbaLogin writes for every login it processes: only that login may be among them. Fixes #10807 (do Set-DbaLogin, Sync-DbaLoginPassword) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
andreasjordan
marked this pull request as ready for review
October 23, 2026 15:22
potatoqualitee
approved these changes
Oct 26, 2026
potatoqualitee
left a comment
Member
There was a problem hiding this comment.
Reviewed at a0eae5d.
Passing -Login through to Get-DbaLogin correctly limits per-login processing while preserving name matching, the system-login exclusion, pipeline input, and multiple-instance behavior. Rename collision detection still uses the server's full login collection.
The new integration regression verifies that the selected login is changed and that unrelated logins are not processed. Reviewed the complete patch, surrounding source, tests, linked issue, discussions, and CI. No material defect found.
All 20 executed exact-head checks passed; one generic Windows job was skipped. No SQL Server integration suite was rerun locally.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #10807
Problem
With
-SqlInstance,Set-DbaLogincalledGet-DbaLogin -SqlInstance $serverwithout-Loginand picked the logins of-Loginout of the result afterwards.Get-DbaLoginprocesses every login it returns (the "Processing [...]" verbose lines in the issue), so changing one login read every login of the instance, which takes long on an instance with many logins or one far away.Sync-DbaLoginPasswordcallsSet-DbaLoginonce per login and destination, so syncing one password did the same.Change
The call passes
-Login. The filter after it stays: it still keeps the##...##system logins out, andGet-DbaLoginmatches the names the same way (-in). Piped logins (-InputObject) are not affected.The other login commands that call
Get-DbaLoginalready pass-Login(Sync-DbaLoginPassword for the source, Sync-DbaLoginPermission, Copy-DbaLogin, Test-DbaLoginPassword). Compare-DbaAgReplicaLogin and Compare-DbaAgReplicaSync compare all logins on purpose.Tests
New context in
tests/Set-DbaLogin.Tests.ps1: of two new logins, one is disabled with-Verbose, and the verbose messagesGet-DbaLoginwrites for every login it processes may name only that one.Lab:
Set-DbaLogin.Tests.ps161 passed on Windows PowerShell 5.1 and on PowerShell 7.6 (single instance SQL Server 2019),Sync-DbaLoginPassword.Tests.ps111 passed on 5.1,dbatools.Tests.ps181 passed and 6 skipped. With theSet-DbaLogin.ps1of development, the new test fails: the verbose messages name all 13 logins of the instance, the second test login among them.馃 Generated with Claude Code