Checks SQL Agent Job owners against a login to validate which jobs do not match that owner.
This function will check all SQL Agent Job on an instance against a SQL login to validate if that login owns those SQL Agent Jobs or not. By default, the function will check against ‘sa’ for ownership, but the user can pass a specific login if they use something else. Only SQL Agent Jobs that do not match this ownership will be displayed, but if the -Detailed switch is set all SQL Agent Jobs will be shown.
To return a list of databases where the owner does not matches sa or renamed sa account.
Test-DbaJobOwner -SqlServer localhost
To return a list of 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-DbaJobOwner -SqlServer localhost -TargetLogin DOMAIN\account