我需要获取可用性组和侦听器名称,连接两者以获得服务器列表,然后使用它来获取资源集群。
到目前为止我所做的:
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 }
主要问题在于 $NetworkName。它返回 System.data.DataRow,而不是连接$AGName_$LNName
(两者之间需要下划线)。