Compare-DbaAgReplicaCredential
View SourceSynopsis
Compares SQL Server Credentials across Availability Group replicas to identify configuration differences.
Description
Compares SQL Server Credentials across all replicas in an Availability Group to identify differences in credential configurations. This helps ensure consistency across AG replicas and detect when credentials have been created or removed on one replica but not others.
This is particularly useful for verifying that junior DBAs have applied security changes to all replicas or for troubleshooting issues where credential configurations have drifted between replicas.
Compares credential names and their associated identities to detect configuration drift.
Syntax
Compare-DbaAgReplicaCredential
[[-SqlInstance] <DbaInstanceParameter[]>]
[[-SqlCredential] <PSCredential>]
[[-AvailabilityGroup] <String[]>]
[-EnableException]
[<CommonParameters>]
Examples
Example: 1
PS C:\> Compare-DbaAgReplicaCredential -SqlInstance sql2016 -AvailabilityGroup AG1
Compares all SQL Server Credentials across replicas in the AG1 Availability Group.
Example: 2
PS C:\> Get-DbaAvailabilityGroup -SqlInstance sql2016 | Compare-DbaAgReplicaCredential
Compares SQL Server Credentials for all Availability Groups on sql2016 via pipeline input.
Optional Parameters
-SqlInstance
The target SQL Server instance or instances. Can be any replica in the Availability Group.
| Property | Value |
|---|---|
| Alias | |
| Required | False |
| Pipeline | true (ByValue) |
| Default Value |
-SqlCredential
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.
| Property | Value |
|---|---|
| Alias | |
| Required | False |
| Pipeline | false |
| Default Value |
-AvailabilityGroup
Specifies one or more Availability Group names to compare credentials across their replicas.
| Property | Value |
|---|---|
| Alias | |
| Required | False |
| Pipeline | false |
| Default Value |
-EnableException
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.
| Property | Value |
|---|---|
| Alias | |
| Required | False |
| Pipeline | false |
| Default Value | False |
dbatools