April 14, 2016 at 1:15 pm
Hello,
I have posted many questions about modifying config files using Powershell, since I am relatively new to PS. I finally got the darn thing working, but now my boss gave me a config file that has a different format to modify.
<?xml version="1.0" encoding="utf-8"?>
<properties name="Template" version="13.4">
<property name="Reports.DMV.TNSEntry" value="Data Source=DEV;Unicode=True" protected="true" />
<property name="Reports.DMW.UserID" value="ABCD" protected="true" />
<property name="Reports.DMV.Password" value="9999" protected="true" />
<property name="Reports.OCD.TNSEntry" value="Data Source=DEVSTAGE;Unicode=True" protected="true" />
<property name="Reports.OCD.UserID" value="WWNA" protected="true" />
</properties>
I would like to be able to modify the Data Sources of this XML file. Does anyone have a script handy that accomplishes this?
Thank you all in advance!
The are no problems, only solutions. --John Lennon
April 14, 2016 at 2:40 pm
Sorry. Not got a script that would do that.
Gaz
-- Stop your grinnin' and drop your linen...they're everywhere!!!
April 15, 2016 at 7:29 am
As much as I appreciate your response, please DO NOT reply with "I don't know how to do this". Once you reply to a post others might think the question was already answered.
I have been struggling with this all week and need to figure something out quickly.
The are no problems, only solutions. --John Lennon
April 15, 2016 at 7:36 am
OK. Sorry.
Gaz
-- Stop your grinnin' and drop your linen...they're everywhere!!!
April 15, 2016 at 10:15 am
Found the solution on MSDN forums:
[xml] $config = get-content "yourxmlfile.xml"
$item = $config.properties.property | ? { $_.name -eq "Reports.DMV.TNSEntry" }
$item.value = "Data Source=...."
Set-Content "yourxmlfile.xml" -Value $config.InnerXml -Force
The are no problems, only solutions. --John Lennon
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply