I want to get values from json file and then store it to the child element in XML file by using powerShell.
[
{
"Modules/ScriptRunnerClassic/Default.aspx": "steve,spenczy",
"Modules/SiteTools/SiteUrls.aspx": "steve,spenczy"
}
]
This is a json from where I'll get the location/s and value/s(steve,spenczy) and below is the XML where I want to store those json values.
<?xml version="1.0" encoding="UTF-8"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<location path="Modules/ScriptRunnerClassic/Default.aspx" xdt:Locator="Match(path)">
<system.web>
<authorization>
<allow users="jimmy,jhon,dev" xdt:Transform="SetAttributes(users)"/>
<deny users="*" />
</authorization>
</system.web>
</location>
<location path="Modules/SiteTools/SiteUrls.aspx" xdt:Locator="Match(path)">
<system.web>
<authorization>
<allow users="jimmy,jhon,dev" xdt:Transform="SetAttributes(users)"/>
<deny users="*" />
</authorization>
</system.web>
</location>
</configuration>
Find the location that was in json file and put its value in <allow users="jimmy,jhon,dev" .../>. It is something like update <allow users="" WHERE <location path="" The output should look like below <allow users="steve,spenczy" .../>:
<?xml version="1.0" encoding="UTF-8"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<location path="Modules/ScriptRunnerClassic/Default.aspx" xdt:Locator="Match(path)">
<system.web>
<authorization>
<allow users="steve,spenczy" xdt:Transform="SetAttributes(users)"/>
<deny users="*" />
</authorization>
</system.web>
</location>
<location path="Modules/SiteTools/SiteUrls.aspx" xdt:Locator="Match(path)">
<system.web>
<authorization>
<allow users="steve,spenczy" xdt:Transform="SetAttributes(users)"/>
<deny users="*" />
</authorization>
</system.web>
</location>
</configuration>