dbatools is a free PowerShell module with over 300 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


Get-DbaAgDatabase

Default view provides most common set of properties for information on the database in an Availability Group(s).

Information returned on the database will be specific to that replica, whether it is primary or a secondary.

This command will return an SMO object, but it is the AvailabilityDatabases object and not the Server.Databases object.

Screenshots

dbatools-Get-DbaAgDatabase

Examples

Returns basic information on all the databases in each Availability Group found on sqlserver2014a.

Get-DbaAgDatabase -SqlInstance sqlserver2014a

Returns basic information on all the databases in the Availability Group AG-a on sqlserver2014a.

Get-DbaAgDatabase -SqlInstance sqlserver2014a -AvailabilityGroup AG-a

Returns basic information on the database AG-Database found in the Availability Group AG-a on server sqlserver2014a.

Get-DbaAgDatabase -SqlInstance sqlserver2014a -AvailabilityGroup AG-a -Database AG-Database

Author

This command was created by Shawn Melton. You can find Shawn on Twitter and his blog.

Get-Help

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

Source Code

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

Related commands