Skip to content

Conversation

@potatoqualitee
Copy link
Member

Summary

This PR recreates and improves upon the functionality from closed PR #8985.

Key Additions

  • New internal function Get-LoginPasswordHash.ps1 to extract password hashes
  • New public command Sync-DbaLoginPassword.ps1 to sync passwords between instances
  • Enhanced Set-DbaLogin.ps1 with -PasswordHash parameter for hash-based password setting
  • Comprehensive test coverage following dbatools patterns
  • Full documentation with usage examples

Implementation Details

The implementation uses Microsoft's sp_help_revlogin approach to extract and apply hashed password values, enabling password synchronization without knowing clear-text passwords.

Use Cases

  • Maintaining consistent passwords across Availability Group replicas
  • Migrating logins between instances without user passwords
  • Disaster recovery scenarios requiring password consistency
  • Syncing dev/test environments with production passwords

Code Quality

All code follows the dbatools style guide:

  • OTBS formatting throughout
  • Splat usage for 3+ parameters with descriptive names
  • Modern PowerShell syntax (no = $true in parameter attributes)
  • Hashtable alignment
  • Proper error handling with EnableException support

Fixes #8980
Fixes #1032

Closes #8985 (supersedes old PR)

🤖 Generated with Claude Code

…lues

This PR recreates and improves upon the functionality from closed PR #8985.

Key additions:
- New internal function Get-LoginPasswordHash.ps1 to extract password hashes
- New public command Sync-DbaLoginPassword.ps1 to sync passwords between instances
- Enhanced Set-DbaLogin.ps1 with -PasswordHash parameter for hash-based password setting
- Comprehensive test coverage following dbatools patterns
- Full documentation with usage examples

The implementation uses Microsoft's sp_help_revlogin approach to extract and apply
hashed password values, enabling password synchronization without knowing clear-text
passwords. This is particularly useful for:
- Maintaining consistent passwords across Availability Group replicas
- Migrating logins between instances
- Disaster recovery scenarios

All code follows the dbatools style guide:
- OTBS formatting throughout
- Splat usage for 3+ parameters with descriptive names
- Modern PowerShell syntax (no = $true in parameter attributes)
- Hashtable alignment
- Proper error handling with EnableException support

Fixes #8980
Fixes #1032

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-authored-by: Chrissy LeMaire <[email protected]>
@potatoqualitee
Copy link
Member Author

@claude we support psv3 too, pls add it not just to psd1 but psm1 for explicit export too

@claude
Copy link

claude bot commented Oct 29, 2025

Claude finished @potatoqualitee's task —— View job


PSv3 Export Support Added ✓

Completed Tasks

  • Read dbatools.psd1 to confirm command is added
  • Read dbatools.psm1 to find explicit export section
  • Add Sync-DbaLoginPassword to psm1 explicit exports
  • Commit and push changes

Summary

Added Sync-DbaLoginPassword to the explicit exports list in dbatools.psm1 at line 543, positioned alphabetically between Get-DbaModule and Sync-DbaLoginPermission. This ensures PSv3 compatibility by explicitly exporting the new command.

The command is now properly exported in both:

  • dbatools.psd1 (FunctionsToExport)
  • dbatools.psm1 (explicit PSv3 export list)

--- | Branch

@potatoqualitee
Copy link
Member Author

@wsmelton pls review 🙏🏼

Copy link
Contributor

@ClaudioESSilva ClaudioESSilva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@potatoqualitee
Copy link
Member Author

hell yeah thank you @ClaudioESSilva !

@potatoqualitee potatoqualitee merged commit 6c63058 into development Nov 5, 2025
15 checks passed
@potatoqualitee potatoqualitee deleted the claude/pr-8985-20251029-1022 branch November 5, 2025 11:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Set-DbaLogin - processing all logins even if you only pass in one Sync-DbaLoginPassword - Support for sync SQL Login passwords between instances

2 participants