How to implement output the existing value from XML file and changed value? I'm using this code for changing configuration in xml files:
[xml]$config = gc $DirectoryPath\Web.config
$config.configuration.appSettings.Item(0).value = "new-value1"
$config.configuration.appSettings.Item(1).value = "new-value2"
$config.Save("$DirectoryPath\Web.config")
I need to get the output of both values (existing and changed). If I use brackets:
(Write-Host($config.configuration.appSettings.Item(0).value) = "new-value1")
I'm geting needed output result:
value1 = new-value1
but the changes in the XML file are not applied.
And also it will be great if I get the existing line number from XML file in output, something like:
value1 = new-value1 at line #10