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

Welcome Forums General PowerShell Q&A How to auto create the ruleset.xml file that is needed to deploy Java securely?

Viewing 2 reply threads
  • Author
    Posts
    • #188839
      Participant
      Topics: 44
      Replies: 79
      Points: 57
      Rank: Member

      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 tags as well as the id location and action permission inner tags.

      Any help here would be much appreciated.

       

      Thank you

    • #188911
      Senior Moderator
      Topics: 8
      Replies: 1140
      Points: 3,922
      Helping Hand
      Rank: Community Hero

      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 
      
      # 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()
      
    • #189145
      Participant
      Topics: 44
      Replies: 79
      Points: 57
      Rank: Member

      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.

Viewing 2 reply threads
  • You must be logged in to reply to this topic.