title: How to Create Text Files from an Array of Values in Powershell
body: <p>I have a text file "list.txt" with a list of hundreds of URL's that I want to parse, along with some common-to-all config data, into individual xml files (config files) using each value in "list.txt", like so:</p>
  
  <p>list.txt contains:</p>
  
  <pre><code>line_1
  line_2
  line_3
  </code></pre>
  
  <p>The boilerplate config data looks like (using <code>line_1</code> as an example):</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;Website xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
    &lt;Url&gt;line_1.mydomain.com&lt;/Url&gt;
    &lt;Title&gt;line_1&lt;/Title&gt;
    &lt;Enabled&gt;true&lt;/Enabled&gt;
    &lt;PluginInName&gt;Tumblr&lt;/PluginInName&gt;
  &lt;/Website&gt;
  </code></pre>
  
  <p>So if "list.txt" contains 100 items, I want 100 config files written with the <code>URL</code> and <code>Title</code> elements individualized.</p>
  
  <p>I have fumbled with several posts on reading the array and on creating text files, but I haven't been able to make any of it work.</p>
  
  <p>What I tried, although it's munged at this point. I'm not sure where I started or how I got to here:</p>
  
  <pre><code>$FileName = "C:\temp\list.txt"
  $FileOriginal = Get-Content $FileName
  
  # create an empty array
  Foreach ($Line in $FileOriginal)
  {    
      $FileModified += $Line
  
      if ($Line -match $pattern) 
      {
          # Add Lines after the selected pattern 
          $FileModified += 'add text'
          $FileModified += 'add second line text'
      } 
  }
  Set-Content $fileName $FileModified
  </code></pre>
  
  <p>This is <strong>way</strong> beyond my neophyte Powershell skills. Can anyone help out?</p>