Sync-DbaLoginSid - Add command to synchronize SQL login SIDs across instances #9955
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.
Not convinced by this, anyone else chime in.
Sync-DbaLoginSid - Synchronize SQL Login SIDs Across Instances
Problem Solved
Fixes a long-standing issue (#3679, opened 2018) where SQL Server environments have the same login with different SIDs across multiple servers. This creates ongoing operational pain:
Repair-DbaDbOrphanUserevery timeWhy Existing Commands Don't Solve This
Copy-DbaLogin -Forcewas suggested in the original issue discussion, but it has critical limitations:The use case requires different passwords per environment (prod vs dev/test) while aligning SIDs to prevent orphaned users.
Implementation Details
Technical Approach
Since SQL Server provides no way to
ALTERa login's SID (theLogin.SidSMO property is read-only after creation), the command:This surgical approach changes only the SID while preserving everything else.
Key Features
Get-DbaLoginoutputConfirmImpact = "High"with full WhatIf supportReal-World Use Cases
Testing
Comprehensive test suite includes:
Code Quality
::new()syntax)= $trueattributes)dbatools.psd1anddbatools.psm1Closes
Closes #3679 (opened June 2018)