title: Change XML tags within PowerShell and keep content.
body: <p>I have exported data from an EventLog using PowerShell and have created a sample Schema to import the data into SQL however there is an issue of the way the data is exported from PowerShell using ConvertToXML.</p>
  
  <p>The exports of the XML looks like this;</p>
  
  <pre><code>&lt;Property Name="Version"&gt;0&lt;/Property&gt;
  
  &lt;Property Name="Qualifiers" /&gt;
  
  &lt;Property Name="Level"&gt;0&lt;/Property&gt;
  
  &lt;Property Name="Task"&gt;14339&lt;/Property&gt;
  
  &lt;Property Name="Opcode"&gt;0&lt;/Property&gt;
  
  &lt;Property Name="Keywords"&gt;-9218868437227405312&lt;/Property&gt;
  
  &lt;Property Name="RecordId"&gt;57963203&lt;/Property&gt;
  
  &lt;Property Name="ProviderName"&gt;Microsoft-Windows-Security-Auditing&lt;/Property&gt;
  </code></pre>
  
  <p>But it should look something like this;</p>
  
  <pre><code>&lt;Version&gt;0&lt;/Version&gt;
  
  &lt;Qualifiers&gt; /&gt;
  
  &lt;Level&gt;0&lt;/Level&gt;
  
  &lt;Task&gt;14339&lt;/Task&gt;
  </code></pre>
  
  <p>The code below identifies the start and end of the property name version and property tag
  and attempts to change it to but unfortunately it changes it without keeping the contents within the tag. I can't seem to kept the value. </p>
  
  <pre><code>$EventLog = (Get-WinEvent -ComputerName xxxxxxx-FilterXML $Query) | ConvertTo-Xml -NoTypeInformation
  
  $EventLogModify = (Get-Content P:\EventTracking\Events.xml) | foreach{$_ -replace '(&lt;Property Name=""Version""&gt;(.*?)&lt;/Property&gt;)', "&lt;Version&gt;&lt;/Version&gt;" };Set-Content P:\EventTracking\Events.xml $EventLogModify;
  </code></pre>