Last active
February 1, 2016 03:08
-
-
Save shiranGinige/1eb3ff34437350eef805 to your computer and use it in GitHub Desktop.
Power-shell to update connection strings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#set the value of this to your own db config | |
$myConnectionString = "Data Source=.;Initial Catalog=<Database>;Integrated Security=True"; | |
$webConfig = '.\Api\Web.config' | |
$dbUpConfig = '.\Database\App.config' | |
$unitTestConfig = '.\Test\App.config' | |
Function updateConfig($config) | |
{ | |
$doc = (Get-Content $config) -as [Xml] | |
$root = $doc.get_DocumentElement(); | |
$activeConnection = $root.connectionStrings.SelectNodes("add"); | |
$activeConnection.SetAttribute("connectionString", $myConnectionString); | |
$doc.Save($config) | |
} | |
updateConfig($webConfig) | |
updateConfig($dbUpConfig) | |
updateConfig($unitTestConfig) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment