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


Get-DbaAvailabilityGroup

By default outputs a small set of information around the Availability Group found on the server.

Screenshots

get-dbaavailabilitygroup

get-dbaavailabilitygroup-simp

get-dbaavailabilitygroup-de

get-dbaavailabilitygroup-pri

Examples

To return basic information on all the Availability Group(s) found on sql2016a

Get-DbaAvailabilityGroup -SqlServer sql2016a

To show only server name, availability groups and role

Get-DbaAvailabilityGroup -SqlServer sql2016a -Simple

To return basic information plus additional info on each replica for all Availability Group(s) on sql2016a

Get-DbaAvailabilityGroup -SqlServer sql2016a -Detailed

To show basic information on the Availability Group AG-a on sql2016a

Get-DbaAvailabilityGroup -SqlServer sql2016a -AvailabilityGroup AG-a

To return true/false if the server, sql2016a, is the primary replica for AG-a Availability Group

Get-DbaAvailabilityGroup -SqlServer sql2016a -AvailabilityGroup AG-a -IsPrimary

Author

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

Get-Help

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

Source Code

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

Related commands