question

inder avatar image
inder asked

Issue with connecting to ReplicationServer with sql authentication

I am trying to use powershell to connect to ReplicationServer and backup replication.The SQL Server Editition is 2008 SP2. It works fine with windows authentication but when I try to connect with sql authentication it shows error New-Object : Cannot find an overload for "ReplicationServer" and the argument count: "1". At .....\Experiment.ps1:34 char:74 + [Microsoft.SqlServer.Replication.ReplicationServer]$var_server=new-object <<<< ("Microsoft.SqlServer.Replication.ReplicationServer") $con + CategoryInfo : InvalidOperation: (:) [New-Object], MethodException + FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand Here is the code snippet [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) { ................. } Any help is highly appreciated.
sql-server-2008replicationpowershell
1 comment
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Other than the sql credentials, did you make any changes to the script when setting it up for the sql login? When using windows auth, did you use $con.Connect() prior to creating a new "Microsoft.SqlServer.Replication.ReplicationServer" ?
0 Likes 0 ·

0 Answers

· Write an Answer

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.