Database Reference
In-Depth Information
F Create or update powershell.exe.config and powershell_ise.config in
$pshome (that is %WINDIR%\SysWOW64\WindowsPowerShell\v1.0 ) for x86
and/or x64 to run PowerShell sessions under .NET 4.0; this is better than the irst
option, but still applies globally. See http://poshcode.org/2045 for details.
F Use custom script code to selectively run a given script block or ile as a .NET 4.0
child process from within PowerShell's .NET 2.0 context. This has the least potential
impact but can make running and debugging more dificult. For example:
https://gist.github.com/882528 .
F Use PowerShell 3.0, which uses .NET 4.0 by default. This is the best option.
If PowerShell 3.0 is available that is the path of least resistance. Otherwise the PowerShell
coniguration modiications are most likely the next best route, unless you have various other
PowerShell scripts or cmdlets (built-in or custom) that may not execute correctly when run
under the .NET Framework 4.0 runtime.
Once conigured, load the assembly as before but specify the 4.X version number.
$odpAssemblyName = "Oracle.DataAccess, Version=4.112.3.0,
Culture=neutral, PublicKeyToken=89b483f429c47342"
[System.Reflection.Assembly]::Load($odpAssemblyName)
To get the assembly name and other details here, you can open %WINDIR%\Microsoft.
NET\assembly in Windows Explorer, navigate to Oracle.DataAccess.dll , and open the
DLL in a dissembler such as dotPeek by JetBrains.
Using OLE DB
One alternative to ODP.NET is using OLE DB (included with ODAC). In this case the assembly
is already loaded; just start creating the types.
$conn = New-Object System.Data.OleDb.OleDbConnection
The only real advantage of OLE DB is your scripts are more portable in that your data access
script logic can be reused for databases other than Oracle. This comes at the cost of slow
performance with COM interop, the loss of some Oracle optimizations, and less functionality
than ODP.NET.
Using Microsoft's Data Provider for Oracle
Microsoft's .NET Framework Data Provider for Oracle ( System.Data.OracleClient ) is
deprecated and generally should not be used. It does provide a more lightweight footprint
than a full ODAC install but has a number of performance and functionality limitations and
is not being maintained.
[System.Reflection.Assembly]::Load("System.Data.OracleClient,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
$conn = New-Object System.Data.OracleClient.OracleConnection
 
Search WWH ::




Custom Search