本文介绍了使用SQL身份验证连接到ReplicationServer的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用PowerShell连接到ReplicationServer和备份复制。 SQL Server Edition是2008 SP2。它在Windows身份验证下可以正常工作,但是当我尝试与SQL Server身份验证连接时,它会显示错误
I am trying to use PowerShell to connect to ReplicationServer and backup replication. The SQL Server Edition is 2008 SP2. It works fine with Windows authentication but when I try to connect with SQL Server authentication it shows error
这是代码段
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.ConnectionInfo")
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo")
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.Replication") | out-null
[reflection.assembly]::LoadWithPartialName("Microsoft.SqlServer.Rmo") | out-null
$script:servername="server1"
$loginname="test"
$passcode="test"
[Microsoft.SqlServer.Management.Common.ServerConnection]$con=new-object ("Microsoft.SqlServer.Management.Common.ServerConnection") $servername,$loginname,$passcode
[Microsoft.SqlServer.Replication.ReplicationServer]$var_server=new-object ("Microsoft.SqlServer.Replication.ReplicationServer") $con
foreach($replicateddatabase in $var_server.ReplicationDatabases)
{
.................
}
推荐答案
在创建ReplicationServer之前尝试打开连接:
Try opening the connection before creating the ReplicationServer:
$con.Connect()
[Microsoft.SqlServer.Replication.ReplicationServer]$var_server=new-object ("Microsoft.SqlServer.Replication.ReplicationServer") $con
这篇关于使用SQL身份验证连接到ReplicationServer的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!