Hi,
I’m opening a power-shell session(64bit) to a remote computer. In that session a lot of scripts(functions) are getting executed. I am trying to connect to an Oracle db server and execute some queries there. Before actual connection, there are couple of tests that are getting executed, pre-deployment tests, where we are checking if connection to the database is good, sftp connection is ok, ssh connection, they are executed one by one. If all that tests are passing, then we start deployment.
Before starting the tests we are loading all the power-shell scripts where those functions are (for db connection test, ssh connection…). Like this :
LogInfo("Load DatabaseActions") $incFile = Resolve-Path .\deployment\DatabaseActions.ps1 . $incFile LogInfo("Load SFTPUpload") $incFile = Resolve-Path .\deployment\SFTPUploadTest.ps1 . $incFile LogInfo("Load SSH") $incFile = Resolve-Path .\deployment\SSH_test.ps1 . $incFil
After they are loaded, tests are starting to execute. We have a separate power-shell script for each test.
First test is connection to the database. There is a script called Db_Connection_test.ps1 which has the following code:
$TestResult = TestDBConnection $RunSettings.ConnectionString
All the needed functions for db connection live in DatabaseActions.ps1 script(including TestDBConnection) :
Add-Type -Path "C:\somePath\Oracle.DataAccess.dll"
<span class=""typ"">Function</span> <span class=""typ"">TestDatabaseConnection</span><span class=""pun"">(</span><span class=""pln"">$connectString</span><span class=""pun"">)</span>
<span class=""pun"">{</span><span class=""pln"">
try
</span><span class=""pun"">{</span>
Code for opening connection to the database
<span class=""pun"">...</span>
<span class=""pun"">}</span>
<span class=""pun"">}</span>
The problem here is that I need to execute the first test in power-shell 32bit because of the Oracle-Client dll. It throws an error in 64bit. But it is one session, so I need to execute that test in 32bit and again continue in 64bit because of the other tests. I tried to start everything in 32bit session, connection to the database is good, but the other tests like ssh connection is falling because the ssh client is 64bit.
I tried this approach by defining an alias when starting the session like this :
Set-Alias Start-PowerShell32 “$env:windir\syswow64\WindowsPowerShell\v1.0\powershell.exe”
And wrap the code in DatabaseActions.ps1 sript like this:
Start-PowerShell32 { ``` Add-Type -Path "C:\somePath\Oracle.DataAccess.dll" ``` ``` Function TestDatabaseConnection($connectString) ``` ``` { try { Code for opening connection to the database ... } } ``` }
But then the TestDatabaseConnection is not known, because it is a new session.
It’s a bit confusing but I tried to explain as much as possible. I hope you can understand what is going on and what is the problem. I really don’t know how to fix this problem. Probably there is a solution but I don’t know it :).
Would like to hear your suggestions how to fix this.
Thanks