I'm trying to write some powershell that will update the value of a xml key value pair based on the value of another key value pair in the same node. Example xml:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<plugins>
<plugin pluginType="plugin1" polling_internal="2" polling_unit="M" enabled="true">
<params>
<add key="Server" value="server1.local" />
<add key="database" value="databasename1" />
</params>
</plugin>
<plugin pluginType="plugin2" polling_internal="2" polling_unit="M" enabled="true">
<params>
<add key="Server" value="server2.local" />
<add key="database" value="databasename2" />
</params>
</plugin>
</plugins>
</configuration>
The real file has hundreds of plugins in it. I want to find all instances of databases called databasename1 - <add key="database" value="databasename1"
and update the corresponding Server key with server name server2.local for example.
I know this can be done with select-xml and xpath, but its beyond me. Any assistance much appreciated.