Answer the question
In order to leave comments, you need to log in
How to change value in config via Powershell?
There is a config, I need to change the values of value in config by getting the value from a text file.
That is: in xml there is <add key="shopId" value="foo"/>
and is a text file, it contains a value.
I either replace the entire file, or duplicate values are written.
Answer the question
In order to leave comments, you need to log in
Yes, you have achieved something.
[XML]$xml = Get-Content "путь до xml"
$xpath = "/configuration/appSettings/add[@value='5' and @key ='shopId']"
$nodes = $xml.SelectNodes($xpath)
foreach ($n in $nodes) {
$n.value = "S013"
}
$xml.Save($xmlFile)
$n.value
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question