From d45e4a0af76779e52db30f94222e352de22528dc Mon Sep 17 00:00:00 2001 From: RG Date: Mon, 14 Apr 2025 22:02:00 +0100 Subject: [PATCH] Added support for non-readable AGs (e.g. a database in a Basic Availability Group is a valid target). --- public/New-DbaDbSnapshot.ps1 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/public/New-DbaDbSnapshot.ps1 b/public/New-DbaDbSnapshot.ps1 index d7ca5f1d2cdd..1c11470068b4 100644 --- a/public/New-DbaDbSnapshot.ps1 +++ b/public/New-DbaDbSnapshot.ps1 @@ -188,6 +188,10 @@ function New-DbaDbSnapshot { Write-Message -Level Warning -Message "$($db.name) is a snapshot, skipping" } elseif ($db.name -in $NoSupportForSnap) { Write-Message -Level Warning -Message "$($db.name) snapshots are prohibited" + } elseif ($db.IsAccessible -ne $true -and ($server.AvailabilityGroups | Where-Object Name -eq $db.AvailabilityGroupName).LocalReplicaRole -eq 'Secondary') { + # Readable secondaries are considered accessible. + # This accounts for every other valid state of an AG (e.g. a database in a Basic Availability Group is a valid target). + $InputObject += $db } elseif ($db.IsAccessible -ne $true) { Write-Message -Level Verbose -Message "$($db.name) is not accessible, skipping" } else { @@ -341,4 +345,4 @@ function New-DbaDbSnapshot { } } } -} \ No newline at end of file +}