Skip to content

Commit

Permalink
Update-SqlPermission (used by Copy-DbaLogin) - Fix for using LoginRen…
Browse files Browse the repository at this point in the history
…ameHashtable together with user different to login (#9313)
  • Loading branch information
andreasjordan authored Apr 11, 2024
1 parent 9fd7d0f commit eb28dfd
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion private/functions/Update-SqlPermission.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ function Update-SqlPermission {
if ($Pscmdlet.ShouldProcess($destination, "Adding $newDbUsername to $dbName.")) {
$sql = $SourceServer.Databases[$dbName].Users[$dbUsername].Script() | Out-String
try {
$destDb.ExecuteNonQuery($sql.Replace("[$dbUsername]", "[$newDbUsername]"))
$destDb.ExecuteNonQuery($sql.Replace("[$dbUsername]", "[$newDbUsername]").Replace("[$loginName]", "[$newLoginName]"))
Write-Message -Level Verbose -Message "Adding user $newDbUsername (login: $newLoginName) to $dbName successfully performed."
} catch {
Stop-Function -Message "Failed to add $newDbUsername (login: $newLoginName) to $dbName on $destination." -Target $db -ErrorRecord $_
Expand Down

0 comments on commit eb28dfd

Please sign in to comment.