XML Node / Element Rename Powershell

rated by 0 users
This post has 0 Replies | 0 Followers

Not Ranked
Posts 1
difference30 Posted: 12-14-2011 5:11 AM

 

Hi Guys

 

You are the master of coding, so I look to you for help.

 

I have exported data from 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.

 

The exports of the XML looks like this;

 

   <Property Name="Version">0</Property>

    <Property Name="Qualifiers" />

    <Property Name="Level">0</Property>

    <Property Name="Task">14339</Property>

    <Property Name="Opcode">0</Property>

    <Property Name="Keywords">-9218868437227405312</Property>

    <Property Name="RecordId">57963203</Property>

    <Property Name="ProviderName">Microsoft-Windows-Security-Auditing</Property>

But it should look something like this;

    < Version>0</Property>

    <Qualifiers> />

    <Level>0</Level>

    < Task>14339</Task>

Can you recommend some sort of looping mechanism to loop round and make the adjustments?

This is my code so far;

$Query = @'
<QueryList>
  <Query Id="0" Path="Security">
    <Select Path="Security">*[System[(Level=4 or Level=0) and (EventID=4771) and TimeCreated[timediff(@SystemTime) &lt;= 1000000]]]</Select>
  </Query>
</QueryList>
'@

   $EventLog = (Get-WinEvent -ComputerName xxxxxx-FilterXML $Query) | ConvertTo-Xml -NoTypeInformation

$EventLog.Save("P:\eventtracking\Events.xml")

 

Regards

 

Page 1 of 1 (1 items) | RSS
Copyright 2012 PowerShell.com. All rights reserved.