0

How can I connect to an Oracle database (11g)? I have a list of oracle servers and I want to execute a query on them from Jump Server (the Jump server has Powershell v2).

Servers are accessible from Jump Server as I am able to access them by UNC path.

Update:

I know it can be done by using ODP.Net connector. But i don't want to use it due to approval.

1 Answer 1

1

You can try the method using an OleDbConnection described here

function Get-OLEDBData ($connectstring, $sql) {            
   $OLEDBConn = New-Object System.Data.OleDb.OleDbConnection($connectstring)            
   $OLEDBConn.open()            
   $readcmd = New-Object system.Data.OleDb.OleDbCommand($sql,$OLEDBConn)            
   $readcmd.CommandTimeout = '300'            
   $da = New-Object system.Data.OleDb.OleDbDataAdapter($readcmd)            
   $dt = New-Object system.Data.datatable            
   [void]$da.fill($dt)            
   $OLEDBConn.close()            
   return $dt            
}
Sign up to request clarification or add additional context in comments.

5 Comments

Thanks for your answer. I will give it a try tomorrow. Voted up.
I checked the above code in my local machine. It seems like i need to install Get-OLEDBData. Do you know where can i get this?
The function Get-OLEDBData is the one described in the code block I pasted.
do i need to install anything? like ODP.net or something. Does it work if i want to run it on multiple server remotly.
I don't have an oracle server with which to test, but the blog I liked seems to indicate all you need is the actual Oracle Client Software installed. If you can't install ANY Oracle Libraries, I doubt you'll be able to access the DB directly at all.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.