title: Replace XML Attributes using PowerShell
body: <p>Currently want to replace the from, to and subject attributes of an XML file using a PowerShell script.</p>
  
  <pre><code>&lt;configuration&gt;
  &lt;configSections&gt;
  &lt;/configSections&gt;
  &lt;elmah&gt;
   &lt;errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName="SqlServer" /&gt;
      &lt;errorMail from="test@test.org" to="test@test.co.uk" cc="" subject="Error email title"/&gt;
      &lt;errorFilter&gt;
      &lt;test&gt;
       &lt;/test&gt;
   &lt;/errorFilter&gt;
  &lt;/elmah&gt;
  </code></pre>
  
  <p>I have tried the following foreach loop but this doesnt seem update the attributes:</p>
  
  <pre><code>$xmlDoc = [XML](Get-Content "$path\Web.config")
  foreach ($item in  $xmlDoc.configuration.elmah.errorMail){
  {$item.from = 'test1@test1.org'}
  {$item.to = 'test2@test2.org'}
  {$item.subject = 'test3'}
  }
  $xmlDoc.Save("$path\Web.config")
  </code></pre>
  
  <p>Anyone help with this script?</p>