dbatools is a free PowerShell module with over 180 SQL Server administration, best practice and migration commands included.


Find-DbaUserObject

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
  • Endpoints
  • Database Schemas
  • Database Roles
  • Database Assemblies
  • Database Synonyms

Screenshots

Examples

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

Author

This command was created by Stephen Bennett. You can find Stephen blogging at sqlnotesfromtheunderground.wordpress.com.

Get-Help

From PowerShell, execute Get-Help Find-DbaUserObject -Detailed for more information on this function.

Source Code

Want to see the source code? View Find-DbaUserObject.ps1 on GitHub
 

Related commands