Recently in experts exchange forum some one asked how to update the web.config using Power Shell
https://www.experts-exchange.com/questions/29075387/Edit-multiple-Config-Files.html?notificationFollowed=201918453#a42415246
Here is the code which you can use to update the web.config, change the filter as per your requirement
https://www.experts-exchange.com/questions/29075387/Edit-multiple-Config-Files.html?notificationFollowed=201918453#a42415246
Here is the code which you can use to update the web.config, change the filter as per your requirement
$files = Get-ChildItem -Path "D:\WebConfig" -Filter "*.config"
foreach($file in $files)
{
$configFile = $file.FullName
$appConfig = [xml](Get-Content $configFile)
$appConfig.configuration.ChildNodes | Where-Object Name -Match 'system.web' | ForEach-Object {
$_.identity.password='testpasswordfrompowershell1';
$_.identity.userName='testuserfrompowershell1';
}
$appConfig.Save("$configFile")
}
foreach($file in $files)
{
$configFile = $file.FullName
$appConfig = [xml](Get-Content $configFile)
$appConfig.configuration.ChildNodes | Where-Object Name -Match 'system.web' | ForEach-Object {
$_.identity.password='testpasswordfrompowershell1';
$_.identity.userName='testuserfrompowershell1';
}
$appConfig.Save("$configFile")
}