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

Please note that documentation and command names may be out of date while we work furiously towards 1.0


Find-DbaDatabase

Allows you to search SQL Server instances for database that have either the same name, owner or service broker guid.

There a several reasons for the service broker guid not matching on a restored database primarily using alter database new broker. Or turn off broker to return a guid of 0000-0000-0000-0000.

Forgot which instance supports your SharePoint farm? No shame, we’re all busy people. Find-DbaDatabase can find it fast with a little asterisk magic.

Screenshots

Examples

To return all database from the SqlInstances that have a database named TestDB with detailed output.

Find-DbaDatabase -SqlServer “DEV01”, “DEV02”, “UAT01”, “UAT02”, “PROD01”, “PROD02” -Pattern TestDB -Detailed

To return all databases from the SqlInstances that have a database name starting with Report with detailed output.

Find-DbaDatabase -SqlServer “DEV01”, “DEV02”, “UAT01”, “UAT02”, “PROD01”, “PROD02” -Pattern Report* -Detailed

To return all database from the SqlInstances that have the same Service Broker GUID with detailed output.

Find-DbaDatabase -SqlServer “DEV01”, “DEV02”, “UAT01”, “UAT02”, “PROD01”, “PROD02” -Property ServiceBrokerGuid -Pattern *-faeb-495a-9898-f25a782835f5 -Detailed

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-DbaDatabase -Detailed for more information on this function.

Source Code

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

Related commands