< Back

Find-DbaDatabase

Mon Jan 13, 2020 10:06 am

NAME Find-DbaDatabase



SYNOPSIS

Find database/s on multiple servers that match criteria you input





SYNTAX

Find-DbaDatabase [-SqlInstance] <Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]> [[-SqlCredential]

<Pscredential>] [[-Property] <String>] [-Pattern] <String> [-Exact <Switch>] [-EnableException <Switch>]

[<CommonParameters>]





DESCRIPTION

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.





PARAMETERS

-EnableException [<Switch>]

By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.

This avoids overwhelming you with "sea of red" exceptions, but is inconvenient because it basically disables

advanced scripting.

Using this switch turns this "nice by default" feature off and enables you to catch exceptions with your own

try/catch.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-Exact [<Switch>]

Search for an exact match instead of a pattern



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-Pattern [<String>]

Value that is searched for. This is a regular expression match but you can just use a plain ol string like

'dbareports'



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-Property [<String>]

What you would like to search on. Either Database Name, Owner, or Service Broker GUID. Database name is the

default.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-SqlCredential [<Pscredential>]

Login to the target instance using alternative credentials. Accepts PowerShell credentials (Get-Credential).



Windows Authentication, SQL Server Authentication, Active Directory - Password, and Active Directory -

Integrated are all supported.



For MFA support, please use Connect-DbaInstance.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-SqlInstance [<Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]>]

The target SQL Server instance or instances.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS



NOTES





Tags: Database

Author: Stephen Bennett, https://sqlnotesfromtheunderground.wordpress.com/



Website: https://dbatools.io

Copyright: (c) 2018 by dbatools, licensed under MIT

License: MIT https://opensource.org/licenses/MIT



-------------------------- EXAMPLE 1 --------------------------



PS C:\\>Find-DbaDatabase -SqlInstance "DEV01", "DEV02", "UAT01", "UAT02", "PROD01", "PROD02" -Pattern Report



Returns all database from the SqlInstances that have a database with Report in the name

-------------------------- EXAMPLE 2 --------------------------



PS C:\\>Find-DbaDatabase -SqlInstance "DEV01", "DEV02", "UAT01", "UAT02", "PROD01", "PROD02" -Pattern TestDB -Exact

| Select-Object *



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

-------------------------- EXAMPLE 3 --------------------------



PS C:\\>Find-DbaDatabase -SqlInstance "DEV01", "DEV02", "UAT01", "UAT02", "PROD01", "PROD02" -Property

ServiceBrokerGuid -Pattern '-faeb-495a-9898-f25a782835f5' | Select-Object *



Returns all database from the SqlInstances that have the same Service Broker GUID with a detailed output



RELATED LINKS

https://dbatools.io/Find-DbaDatabase