Common Database Connection String ( Powershell) This topic contains 2 replies, has 2 voices, and was last updated by Nick 3 years, 10 months ago. Author Posts May 21, 2014 at 7:27 am #15465 NickParticipant Greetings, I have requirement to create common connection string to execute all SQL script file or Query and i could not find any example. Please could you help me get an example or provide some input based on your experience. This will help to achieve my tasks ..! using power shell v2.0 Thanks VJ May 21, 2014 at 7:40 am #15466 JoakimParticipant Hi, is it the actual connection string you need help with or how to conect to the database and get data? If you want to have a connectionstring available for all your scripts you can add the connection string to your $PROFILE. That ensures that is is available for your scripts. Don Jones have a great example for how you can do this in his code for generating historical reports. The code is available from the OneDrive folder. May 21, 2014 at 7:55 am #15468 NickParticipant Hi joakim, Thank you so much for your quick reply. Hers's the steps i would like to connect database :- 1. Create common script, should have only the connections string info like user/pwd & server & database name with encrypted PWD. 2. Create .ps1 script to call the connection string and then open connection to execute the QUERY or procedure / .sql file 3. close the connection sting in the .ps1 file 4. Done Author Posts You must be logged in to reply to this topic.