From c5ea03f602b164850be290be24feaeadb54b4d80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mich=C3=A8le=20Tahay?= <62601152+michele-tahay-kohera@users.noreply.github.com> Date: Thu, 28 Aug 2025 14:51:34 +0200 Subject: [PATCH 1/2] Bugfix for finding $Replicas The Find-DbaInstance returns an object for the browser service when there are multiple (named) instances on one machine. This makes the subsequent Get-DbaAvailabilityGroup call fail. --- source/checks/HADR.Tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/checks/HADR.Tests.ps1 b/source/checks/HADR.Tests.ps1 index 8a14d606..0be58439 100644 --- a/source/checks/HADR.Tests.ps1 +++ b/source/checks/HADR.Tests.ps1 @@ -37,7 +37,7 @@ function Get-ClusterObject { $PreviousClusterNode = $AGResource.OwnerNode.Name # We get cluster node owner first ... # We need then for each owner to find out the corresponding replicas => SQL Instance Name + Port - $Replicas = Find-DbaInstance -ComputerName $AGResource.OwnerNode.Name + $Replicas = Find-DbaInstance -ComputerName $AGResource.OwnerNode.Name | Where-Object {$_.Services.ServiceName -ne $null } } # Finally for each replica detected (SQL Server + Port) From 604f972078a32ae4f1e5ac3b63f06bfbd28f5ff7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mich=C3=A8le=20Tahay?= <62601152+michele-tahay-kohera@users.noreply.github.com> Date: Thu, 28 Aug 2025 14:54:42 +0200 Subject: [PATCH 2/2] $return object should not get nullified When an error occurs in getting AG info, the whole $result object should not be nullified --- source/checks/HADR.Tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/checks/HADR.Tests.ps1 b/source/checks/HADR.Tests.ps1 index 0be58439..14352c88 100644 --- a/source/checks/HADR.Tests.ps1 +++ b/source/checks/HADR.Tests.ps1 @@ -53,7 +53,7 @@ function Get-ClusterObject { } } catch { - $return = $null + $return.AvailabilityGroups[$AGResource.Name] = 'FailedToConnect' } }