Executing Oracle SQLPlus in a Powershell Invoke-Command statement against a remote machine
Posted
by
Scott Muc
on Server Fault
See other posts from Server Fault
or by Scott Muc
Published on 2010-09-13T16:12:46Z
Indexed on
2011/02/03
15:27 UTC
Read the original article
Hit count: 534
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?
© Server Fault or respective owner