I am trying to generate a replication scripts for all publications that uses powershell script calling through a SQL Agent job.
Code works in lower version, but i am getting below error for 2022.
Could you please help me alter the step!
A job step received an error at line 37 in a PowerShell script. The corresponding line is '$repsvr=New-Object "Microsoft.SqlServer.Replication.ReplicationServer" $sqlserver
'. Correct the script and reschedule the job. The error information returned by PowerShell is: 'Could not load file or assembly 'Microsoft.SqlServer.ConnectionInfo, Version=17.100.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The system cannot find the file specified.
'