Verified issue does not already exist?
No, I did not search
What error did you receive?
The Get-DbaAvailabilityGroup function returns null/empty when testing for a sql server instance in a contained AG
Steps to Reproduce
Set-DbatoolsInsecureConnection
$test = Get-DbaAvailabilityGroup -SqlInstance ServerInContainedAG #this server is in contained AG
if ($test) {
"It is part of Containde AG"
} {
"It is not part of Containde AG"
}
$test
it is not part of Containde AG
This is the TSQL that returns the listener name from the containde AG
SELECT TOP 1
agl.dns_name AS listener_name
FROM sys.availability_groups ag
LEFT JOIN sys.availability_group_listeners agl
ON ag.group_id = agl.group_id
WHERE ag.is_contained = 1
and using this TSQL returns the name ofthe listener, but when use the Get-DbaAvailabilityGroup returns null/empty
Please confirm that you are running the most recent version of dbatools
2.9.0
Other details or mentions
No response
What PowerShell host was used when producing this error
Windows PowerShell (powershell.exe)
PowerShell Host Version
Name Value
PSVersion 5.1.17763.6893
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17763.6893
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
SQL Server Edition and Build number
Microsoft SQL Server 2022 (RTM-CU25-GDR) (KB5101347) - 16.0.4262.2 (X64) Jun 18 2026 14:30:08 Copyright (C) 2022 Microsoft Corporation Enterprise Edition: Core-based Licensing (64-bit) on Windows Server 2022 Standard 10.0 (Build 20348: ) (Hypervisor)
.NET Framework Version
.NET Framework 4.8.4775.0
Verified issue does not already exist?
No, I did not search
What error did you receive?
The Get-DbaAvailabilityGroup function returns null/empty when testing for a sql server instance in a contained AG
Steps to Reproduce
Set-DbatoolsInsecureConnection
$test = Get-DbaAvailabilityGroup -SqlInstance ServerInContainedAG #this server is in contained AG
if ($test) {
"It is part of Containde AG"
} {
"It is not part of Containde AG"
}
$test
it is not part of Containde AG
This is the TSQL that returns the listener name from the containde AG
SELECT TOP 1
agl.dns_name AS listener_name
FROM sys.availability_groups ag
LEFT JOIN sys.availability_group_listeners agl
ON ag.group_id = agl.group_id
WHERE ag.is_contained = 1
and using this TSQL returns the name ofthe listener, but when use the Get-DbaAvailabilityGroup returns null/empty
Please confirm that you are running the most recent version of dbatools
2.9.0
Other details or mentions
No response
What PowerShell host was used when producing this error
Windows PowerShell (powershell.exe)
PowerShell Host Version
Name Value
PSVersion 5.1.17763.6893
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17763.6893
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
SQL Server Edition and Build number
Microsoft SQL Server 2022 (RTM-CU25-GDR) (KB5101347) - 16.0.4262.2 (X64) Jun 18 2026 14:30:08 Copyright (C) 2022 Microsoft Corporation Enterprise Edition: Core-based Licensing (64-bit) on Windows Server 2022 Standard 10.0 (Build 20348: ) (Hypervisor)
.NET Framework Version
.NET Framework 4.8.4775.0