Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export-DbaUser should include schema ownership #9458

Open
rickloveslamp opened this issue Aug 29, 2024 · 0 comments
Open

Export-DbaUser should include schema ownership #9458

rickloveslamp opened this issue Aug 29, 2024 · 0 comments
Labels
feature triage required New issue that has not been reviewed by maintainers

Comments

@rickloveslamp
Copy link
Contributor

Summarize Functionality

This isn't quite a bug because there is not anything broken, per se, so I put it as a feature. But something that tripped us up when recreating security using Export-DbaUser was the user did not have its schema ownership scripted. If you have schema level permissions you are covered, but if you own the whole schema then the output is empty.

Is there a command that is similiar or close to what you are looking for?

Yes

Technical Details

If you stick this somewhere around line 362 it should cover it:

#Schema Ownership
foreach ($schema in $db.Schemas | Where-Object {$_.Owner -eq $dbuser.Name}) {
    $outsql += "ALTER AUTHORIZATION ON SCHEMA::[{0}] TO [{1}]" -f $schema.Name, $schema.Owner
}
@rickloveslamp rickloveslamp added feature triage required New issue that has not been reviewed by maintainers labels Aug 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature triage required New issue that has not been reviewed by maintainers
Projects
None yet
Development

No branches or pull requests

1 participant