How to auto create the ruleset.xml file that is needed to deploy Java securely?

I created scripts to fetch all the URLs in my environment, but now I am trying to determine how I can auto create an xml file that needs to be in the following format:

I have every URL that I need to place in the id location=“” portion of the xml file in a completely separate text file in a simple list format on separate lines, but I am at a loss as to how I go about telling PowerShell to read the URL in one file and then paste that in the id location=“” of my ruleset.xml file.

So, for each URL, I need to create a new line that contains a new set of <rule> </rule> tags as well as the id location and action permission inner tags.

Any help here would be much appreciated.


Thank you

its doable, how are the URLs stored for each rule ? are those in separate files for each role ?

at high level,

#Get all the roles from XML, I suggest use
[XML]$XML = Get-Content -Path <path to rules xml>

# get the rules node, assuming there is a parent node rules and all rule nodes are under that parent node in xml
$Rules = $XML.SelectNodes("//rules/rule")

# Iterate for each rule in rules
Foreach($Rule in $Rules){
    # get the url for this rule and store in $Url variable
    $Rule.Id.Location = $Url

$XML.Save(<destination xml location>)

The URLs are ALL in the same text file in a list format on separate lines.

I will give your script a whirl and let you know how it goes.

Thank you very much for your help, I appreciate it.