I need to get Availability Group and Listener name, concatenate both for a list of servers and then use it to get resource cluster.
What I've done so far:
foreach ($cluster in GC "D:\TEST\Servers_List_TEST.txt")
{
$AGName = invoke-sqlcmd -Serverinstance $cluster -query "select left(name,25) as ' ' from sys.availability_groups"
$LNName = invoke-sqlcmd -Serverinstance $cluster -query "select left(dns_name,25) as ' ' from sys.availability_group_listeners"
$NetworkName = "$AGName_$LNName"
Get-ClusterResource -cluster $cluster -name $NetworkName | Get-ClusterParameter HostRecordTTL,RegisterAllProvidersIP }
The main issue is on $NetworkName. It's returning System.data.DataRow, instead of concatenating $AGName_$LNName
( underscore is necessary between both ).