This function will check all databases on an instance against a SQL login to validate if that login owns those databases or not. By default, the function will check against ‘sa’ (or renamed sa account) for ownership, but the user can pass a specific login if they use something else. Only databases that do not match this ownership will be displayed, but if the -Detailed switch is set all databases will be shown.
Return all databases where the owner does not match ‘sa’.
Test-DbaDatabaseOwner -SqlServer localhost
Return all databases where the owner does not match ‘DOMAIN\account’. Note that TargetLogin must be a valid security principal that exists on the target server.
Test-DbaDatabaseOwner -SqlServer localhost -TargetLogin ‘DOMAIN\account’