Search code examples
scriptingpowershelloledbwindows-server-2008-r2

powershell 2.0 on Windows server 2008 R2 cannot connect with OLEDB connection


I developed a powershell application on an XP box that made an OLEDB connection to a Sybase server to extract data that is then inserted into a SQL Server 2008 database instance. After debugging this script and ensuring the process operated correctly, I moved the script to a new Windows Server 2008 R2 box. In order to connect to the Sybase instance I installed the Sybase 12.5.2 client as I had done on the XP box. However, running the script failed with the message: Exception calling "open" with "0" argument(s): "The 'Sybase.ASEOLEDBProvider.2' provider is not registered on the local machine.

The base connection string was derived from connectionStrings.com and worked on the XP so I do not believe there is a syntax issue per se. So, I manually registed the OLEDB dll with the command: regsvr32 sydaase.dll

it registered with no errors.

Cutting out the pertinent lines of the script, the connection logic sequence is $dbConn = new-object System.Data.oldeb.oledbConnection $dbConn.connectionString = "Provider=Sybase.ASEOLEDBProvider.2; server name = myServer; port address = xxx; initial catalog = xxx; user Id = xxx; Password = xxxx"

I have replaced my data with xxx in this example.

I am not clear why this ran without issue on the XP box, but is failing to do so on the Windows Server box though I followed the same configuration process.


Solution

  • I'll wager that you are trying this on a 64 bit R2 machine, and using the 64 bit PowerShell console. There are no native 64 bit OLEDB drivers, only 32 bit - use the 32 bit console and you should be ok.