Have a developer, DBA or other employee leaving the company and need to know what they own? This command can help. It searches SQL Server to find user-owned objects (ie. not dbo or sa) or for any object owned by a specific user specified by the Pattern parameter.
Looks at the below list of objects to see if they are either owned by a user or a specific user (using the parameter -Pattern)
- Database Owner
- Agent Job Owner
- Used in Credential
- Used in Proxy
- SQL Agent Steps using a Proxy
- Database Schemas
- Database Roles
- Database Assemblies
- Database Synonyms
Searches user objects for owner ad\stephen
Find-DbaUserObject -SqlInstance DEV01 -Pattern ad\stephen
Shows all user owned (non-sa, non-dbo) objects and verbose output
Find-DbaUserObject -SqlInstance DEV01 -Verbose
This command was created by Stephen Bennett. You can find Stephen blogging at sqlnotesfromtheunderground.wordpress.com.