troubleshooting Question

Powershell and SQL Connections

Avatar of campbell1972
campbell1972 asked on
Powershell* ise
4 Comments2 Solutions251 ViewsLast Modified:
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!
ASKER CERTIFIED SOLUTION
campbell1972

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros