Forum Discussion
fweymouth
Jun 15, 2022Copper Contributor
Passing credentials to SQL connection string
Hello. I am new to PowerShell and would really appreciate some help! I have a working script (Example A) which allows me to connect to SQL servers in my current domain using windows authenticatio...
farismalaeb
Jun 16, 2022Iron Contributor
Hi
I am not a SQL expert but let me tell you what I think
It's not a the PowerShell use the logged-in cred to auth, its the connection string and what parameter support
You cannot pass the username and password through a connection string as Windows Auth. it wont work
The other way is to enable SQL Auth on the remote server and connect using SQL Auth
One way I think you can do it is to invoke Enter-PSSession and execute the SQL query on the remote server, But still not sure if it will work like this. Its just an idea.
- fweymouthJun 16, 2022Copper ContributorGood to know, thanks for the info!