Link to home
Start Free TrialLog in
Avatar of campbell1972
campbell1972

asked on

Powershell and SQL Connections

I am finding a discrepancy between Powershell ISE and Powershell running under the Administrator account.

My script contains a number of connections to SQL, all of which work without issue under ISE.

However, when executing from a Powershell prompt, a number of the SQL connections fail with the error: Exception calling Open with 0 argument(s): The ConnectionString property has not been initialized.

The code which is failing is as follows:

$connectionDB = New-Object System.Data.OleDb.OleDbConnection $connectionDetailsDB
$command22 = New-Object System.Data.OleDb.OleDbCommand $SQLConfigOptions, $connectionDB
$connectionDB.Open()

This format is used consistently throughout the script so the only difference appears to be the Powershell environment under which it executes.

As always, any pointers appreciated!
SOLUTION
Avatar of Dan McFadden
Dan McFadden
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of campbell1972
campbell1972

ASKER

Dan

I'll look to post some of the script later today.

However, how does this account for it running as expected under ISE?

JC
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Issue identified when parsing the file for unique variables