Executing Oracle SQLPlus in a Powershell Invoke-Command statement against a remote machine
- by Scott Muc
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?