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


Get-DbaDatabase

The Get-DbaDatabase command gets SQL database information for each database that is present in the target instance(s) of SQL Server. If the name of the database is provided, the command will return only the specific database information.

Screenshots

Examples

Returns all databases on the local default SQL Server instance

Get-DbaDatabase -SqlServer localhost

Returns only the system databases on the local default SQL Server instance

Get-DbaDatabase -SqlServer localhost -NoUserDb

Returns only the user databases on the local default SQL Server instance

Get-DbaDatabase -SqlServer localhost -NoSystemDb

Returns databases on multiple instances piped into the function

‘localhost’,’sql2016′ | Get-DbaDatabase

Author

This command was created Garry Bargsley. You can find Garry on tweeting on Twitter and blogging at garrybargsley.com

Get-Help

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

Source Code

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

Related commands