Created
February 15, 2016 00:02
-
-
Save shiranGinige/c2ebd7f44e7f64187862 to your computer and use it in GitHub Desktop.
PS to update different configs
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=<<yourdatabase>>;Integrated Security=True"; | |
$scriptDir = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent | |
$webConfig = $scriptDir + '\PeopleStreme.Api\Web.config' | |
$dbUpConfig = $scriptDir + '\PeopleStreme.Database\App.config' | |
$unitTestConfig = $scriptDir + '\Config\App.config' | |
Function updateConfig($webConfig) | |
{ | |
Write-Host "Reading config" -ForegroundColor Green | |
$doc = (Get-Content $webConfig) -as [Xml] | |
$root = $doc.get_DocumentElement(); | |
$activeConnection = $root.connectionStrings.SelectNodes("add"); | |
$activeConnection.SetAttribute("connectionString", $myConnectionString); | |
Write-Host "Writing config" -ForegroundColor Green | |
$doc.Save($webConfig) | |
} | |
updateConfig($webConfig) | |
updateConfig($dbUpConfig) | |
updateConfig($unitTestConfig) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment