同样的代码 ,检测alwayson 再执行SetDefaultInitFields时报错,有谁知道怎么修改下吗


PowerShell交流中心同样的代码 ,检测alwayson 再执行SetDefaultInitFields时报错,有谁知道怎么修改下吗
0
telnet4730 asked 6 年 ago

$ServerName=”wYDDJZ-PWA3-020″ #hostname

$serverObject = New-Object Microsoft.SqlServer.Management.SMO.Server($ServerName)
if($serverObject -eq $null)
{
echo 00000
}
$serverObject.SetDefaultInitFields([Microsoft.SqlServer.Management.Smo.AvailabilityGroup], $true)
$serverObject.SetDefaultInitFields([Microsoft.SqlServer.Management.Smo.AvailabilityReplica], $true)
$serverObject.SetDefaultInitFields([Microsoft.SqlServer.Management.Smo.DatabaseReplicaState], $true)

 

在SetDefaultInitFields的时候提示无法连接到服务器 wYDDJZ-PWA3-020

使用“2”个参数调用“SetDefaultInitFields”时发生异常:“无法连接到服务器 wYDDJZ-PWA3-020。”
所在位置 E:\20180320云订单监控\check_cluster_alwaysonv2.ps1:119 字符: 1
+ $serverObject.SetDefaultInitFields([Microsoft.SqlServer.Management.Smo.Availabil …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : ConnectionFailureException

使用“2”个参数调用“SetDefaultInitFields”时发生异常:“无法连接到服务器 wYDDJZ-PWA3-020。”
所在位置 E:\20180320云订单监控\check_cluster_alwaysonv2.ps1:120 字符: 1
+ $serverObject.SetDefaultInitFields([Microsoft.SqlServer.Management.Smo.Availabil …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : ConnectionFailureException

使用“2”个参数调用“SetDefaultInitFields”时发生异常:“无法连接到服务器 wYDDJZ-PWA3-020。”
所在位置 E:\20180320云订单监控\check_cluster_alwaysonv2.ps1:121 字符: 1
+ $serverObject.SetDefaultInitFields([Microsoft.SqlServer.Management.Smo.DatabaseR …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : ConnectionFailureException