We have a basic powershell script that attempts to execute SQLPlus.exe on a remote machine. The remote does not have Oracle Instant client installed, but we have bundled all the necesary dlls in a remote folder. For example we have sqlplus.exe and dependencies in the directory C:\temp\oracle.
If I navigate to that path on the remote server and execute sqlplus.exe it runs just fine. I get the prompt for username.
If I go:
Invoke-Command -comp remote.machine.host -ScriptBlock { C:\temp\oracle\sqplus.exe }
I get the following:
Error 57 initializing SQL*Plus
+ CategoryInfo : NotSpecified: (Error 57 initializing SQL*Plus:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
Error loading message shared library
Thinking that it's potentially a PATH issue I tried the following:
Invoke-Command -comp remote.machine.host -ScriptBlock { $env:ORACLE_HOME= "C:\temp\oracle"; $env:PATH = "$env:ORACLE_HOME; C:\temp\oracle\sqlplus.exe }
This had the same result.
The error code is not very helpful and is extremely frustrating since it does work when I log on to the machine. What is powershell remoting doing that's making this not work?
Best Answer
This smells to me like an environment issue. Why can't you install the client properly on the remote system?
Is there any way you can dump your environment from the powershell script just prior to invoking SQL*Plus? If so, compare that with your environment when you're logged in and it works. Perhaps something like this:
Note: there appears to be a missing double quote in your PATH statement that I added in. I assume that was a transcription error.