Thor Logo dbatools

DbOwner

Set-DbaDbOwner

Michael Fal (@Mike_Fal), mikefal.net

Set-DbaDbOwner View Source Michael Fal (@Mike_Fal), mikefal.net Windows, Linux, macOS Synopsis Changes database ownership to a specified login when current ownership doesn’t match the target. Description Changes database ownership to standardize who owns your databases across an instance. This is particularly useful for maintaining consistent ownership patterns after restoring databases from other environments, where databases may have orphaned owners or inconsistent ownership. By default, the function sets ownership to ‘sa’ (or the renamed sysadmin account), but you can specify any valid login.

Read more

Test-DbaDbOwner

Michael Fal (@Mike_Fal), mikefal.net

Test-DbaDbOwner View Source Michael Fal (@Mike_Fal), mikefal.net Windows, Linux, macOS Synopsis Identifies databases with incorrect ownership for security compliance and best practice enforcement. Description This function compares the current owner of each database against a target login and returns only databases that do NOT match the expected owner. By default, it checks against ‘sa’ (or the renamed sysadmin account if ‘sa’ was changed), but you can specify any valid login.

Read more