I have a PS script that is executed from a TSQL Agent Job. It uses ADO to retrieve SQL data and call SQL stored procs. That part all works well. But at the very end it calls a custom DLL and it chokes when trying to call a method in the class. It says that it cannot establish a connection to SQL Server, when I am trying to call a class in the DLL. And it allows the instantiation of the class but does not like the call. Very strange.
I have run at work on several differen SQL Servers and PS versions without issue. At the client's site they have SQL 2008 R2 and PS v2.0 - both of which I have tested on.
The relevant code is
$SecureAES = new-object SecureAES ($parm1, $parm2,$parm3) $SecureText = $SecureAES.DecodeAndDecryptString($SecuritySetting, $SecureAES.GetKey())
The error is ... Executed as user: HTC-SQL-02\SYSTEM. A job step received an error at line 257 in a PowerShell script. The corresponding line is ' $SecureText = $SecureAES.DecodeAndDecryptString($SecuritySetting, $SecureAES.GetKey()) '. Correct the script and reschedule the job. The error information returned by PowerShell is: 'Exception calling "DecodeAndDecryptString" with "2" argument : "A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)" '. Process Exit Code -1. The step failed.
Any help would be appreciated. We did enable Named Pipes for SQL Server Network Onfiguration, Protocols for MSSQLSERVER and restart the server. But the message seems so unlikely for trying to access a DLL.
Any help would be appricated. I don't even know where to start.
I had forgotten that the DLL does write some log records to a SQL Server. I am stupid. Think I forgot to remove the hardcoded string connection (with a local development server) that used for testing the log records write. Too many things going on. Got jerked away during the testing and then tried to pick back up.
Powered by IDERA