Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9056403
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T14:11:53+00:00 2026-06-16T14:11:53+00:00

Below is the content of source/destine XML(Web.Config) file, in which I have to replace

  • 0

Below is the content of source/destine XML(Web.Config) file, in which I have to replace value of an attribute. This needs to be done for several config files, so need your help to get this done using powershell. I did try with the codes for replacing strings which are available in stackOverFlow- but dint make it..

<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->

<configuration>
<connectionStrings>

<add name="PrcEntities"
   providerName="System.Data.SqlClient"
   connectionString="Server=DDD05DB01,63518;Database=BBBDB001;Trusted_Connection=true;multipleactiveresultsets=true;Pooling=false"/>

<add name="CoreItemContext"
 providerName="System.Data.SqlClient"
 connectionString="Server=DDD15DB03,63520;Database=BBBDB002;Trusted_Connection=true;multipleactiveresultsets=true;Pooling=true"/>

</connectionStrings>
..

..

....

</configuration>

This is my Powershell code to query the attribute named “ConnectionString” from above XML file

$Path = "C:\Ps\Web.config" 
$con="connectionString"   
[xml]$Types = Get-Content $Path 
Select-Xml -Xml $Types -XPath "//add" | Select-Object -ExpandProperty Node|Select-Object name,$con | Format-List 

Which will result in :

name : PrcEntities
connectionString : Server=DDD05DB01,63518;Database=BBBDB001;Trusted_Connection=true;
multipleactiveresultsets=true;Pooling=false

name : CoreItemContext
connectionString : Server=DDD15DB03,63520;Database=BBBDB002;Trusted_Connection=true;
multipleactiveresultsets=true;Pooling=true

Now, I want to replace the value of attribute ‘connectionString‘ with details like:
Server=DBD05DB01,63518;Database=DDBDB001;Trusted_Connection=true;multipleactiveresultsets=true;Pooling=false in both the places(PrcEntities & CoreItemContext)

This change should be saved to same source file. Please help me on this!!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T14:11:56+00:00Added an answer on June 16, 2026 at 2:11 pm
    $path = "D:\Web.Config"
    [xml]$xml = Get-Content $path 
    
    $xml.configuration.connectionStrings.add | Foreach-Object {
        $_.connectionString = 'Server=DBD05DB01,63518;Database=DDBDB001;Trusted_Connection=true;multipleactiveresultsets=true;Pooling=false'
    }
    
    $xml.Save($path)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string which has the below content String msg = The variables
okay, so i have a text file with example content below line1with some random
I have the below xpath expression //div[@class=post-content]//img which runs on a html page, scanning
How to read the below xml file and write its content into a plain
I have AJAX call to one XML file and the source code is given
I am trying to download a source code file from a web site which
I have a xml file content as string in my servlet, I need to
I have 4 divs with content like below: <div class=prodNav-Info-Panel>content</div> <div class=prodNav-Usage-Panel>content</div> <div class=prodNav-Guarantee-Panel>content</div>
I have an example json as below: { Passwd:String content, Userme:String content } how
I have a TabControl with templated content as below: <TabControl x:Name=Items SelectedItem={Binding ActiveItem} TabStripPlacement=Left

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.