Chrissy LeMaire (@cl) | Stuart Moore (@napalmgram), Andreas Jordan
Get-DbaAgBackupHistory View Source Chrissy LeMaire (@cl) , Stuart Moore (@napalmgram), Andreas Jordan Windows, Linux, macOS Synopsis Retrieves backup history from msdb across all replicas in a SQL Server Availability Group
Description Queries the msdb backup history tables across all replicas in an Availability Group and aggregates the results into a unified view. This function automatically discovers all replicas (either through a listener or by querying individual replicas) and combines their backup history data, which is essential since backups can be taken from any replica but are only recorded in the local msdb.
Get-DbaAgDatabase View Source Shawn Melton (@wsmelton), wsmelton.github.io Windows, Linux, macOS Synopsis Retrieves availability group database information and synchronization status from SQL Server instances.
Description Retrieves detailed information about databases participating in SQL Server availability groups, including their synchronization state, failover readiness, and replica-specific status. This function queries the availability group configuration from each SQL Server instance to return database-level health and status information that varies depending on whether the replica is primary or secondary.
Get-DbaAgDatabaseReplicaState View Source Andreas Jordan (@andreasjordan) Windows, Linux, macOS Synopsis Retrieves the runtime state of databases participating in availability groups across all replicas.
Description Retrieves comprehensive health monitoring information about databases participating in SQL Server availability groups, similar to the SSMS AG Dashboard. This function returns detailed database replica state information for all replicas in the availability group.
The class Microsoft.SqlServer.Management.Smo.DatabaseReplicaState represents the runtime state of a database that’s participating in an availability group.
Get-DbaAgHadr View Source Shawn Melton (@wsmelton), wsmelton.github.io Windows, Linux, macOS Synopsis Retrieves the High Availability Disaster Recovery (HADR) service status for SQL Server instances.
Description Checks whether Availability Groups are enabled at the service level on SQL Server instances. This is a prerequisite for creating and managing Availability Groups, as HADR must be enabled before you can configure any AG functionality. Returns the computer name, instance name, and the current HADR enabled status (true/false) for each specified instance, making it useful for environment audits and troubleshooting AG setup issues.
Get-DbaAgListener View Source Viorel Ciucu (@viorelciucu) Windows, Linux, macOS Synopsis Retrieves availability group listener configurations including IP addresses and port numbers.
Description Retrieves availability group listener configurations from SQL Server instances, providing essential network details needed for client connections and troubleshooting. This function returns listener names, port numbers, IP configurations, and associated availability groups, which is crucial for validating listener setup and diagnosing connection issues. Use this when you need to document your AG infrastructure, verify listener configurations after setup, or troubleshoot client connectivity problems.
Get-DbaAgReplica View Source Shawn Melton (@wsmelton) , Chrissy LeMaire (@cl) Windows, Linux, macOS Synopsis Retrieves availability group replica configuration and status information from SQL Server instances.
Description Retrieves detailed information about availability group replicas including their current role, connection state, synchronization status, and failover configuration. This function helps DBAs monitor replica health, verify failover readiness, and troubleshoot availability group issues without manually querying system views. Returns comprehensive replica properties like backup priority, endpoint URLs, session timeouts, and read-only routing lists for availability group management and compliance reporting.
Get-DbaAvailabilityGroup View Source Shawn Melton (@wsmelton) , Chrissy LeMaire (@cl) Windows, Linux, macOS Synopsis Retrieves Availability Group configuration and status information from SQL Server instances.
Description Retrieves detailed Availability Group information including replica roles, cluster configuration, database membership, and listener details from SQL Server 2012+ instances.
This command helps DBAs monitor AG health, identify primary replicas for failover planning, and generate inventory reports for compliance or troubleshooting. The default view shows essential properties like replica roles, primary replica location, and cluster type, while the full object contains comprehensive AG configuration details.
Grant-DbaAgPermission View Source Chrissy LeMaire (@cl), netnerds.net Windows, Linux, macOS Synopsis Grants specific permissions to logins for availability groups and database mirroring endpoints.
Description Grants permissions to SQL Server logins for availability groups (Alter, Control, TakeOwnership, ViewDefinition) and database mirroring endpoints (Connect, Alter, Control, and others). Essential for setting up high availability and disaster recovery scenarios where service accounts or users need access to manage or connect to availability group resources.
Invoke-DbaAgFailover View Source Chrissy LeMaire (@cl), netnerds.net Windows, Linux, macOS Synopsis Performs manual failover of an availability group to make the target instance the new primary replica.
Description Performs manual failover of an availability group to make the specified SQL Server instance the new primary replica. The function connects to the target instance (which must be a secondary replica) and promotes it to primary, while the current primary becomes secondary.
Join-DbaAvailabilityGroup View Source Chrissy LeMaire (@cl), netnerds.net Windows, Linux, macOS Synopsis Adds a SQL Server instance as a secondary replica to an existing availability group.
Description Adds a SQL Server instance as a secondary replica to an existing availability group that has already been created on the primary replica. This command is typically used after creating the availability group on the primary server and before adding databases to the group.