I am trying to parse some xml log entries and export the data as rows in a CSV file. The format of the input file looks like:
"
The Messages envelope contains a couple of thousands of Message children.
I am trying to extract the values of two attributes in their raw form and for the third attribute I want to apply a regular expression that captures a group and retain the group match. E.g. The custom object I would like to end up in the end should have attributes “value1”, “value2”, and Regex group match of “value3”.
What I have at the moment is
[xml]$results = get-content log_messages.log $results.LogMessages.LogMessage | Where-Object {$_.messageID -like "S6F*"} | Select-Object -Property time,message,'#cdata-section' | Export-Csv parse_results.csv -Delimiter "," -NoTypeInformation
This yields a csv file with three columns, one for each property. What I really need is that the third column be the capture group applied on the value in ‘#cdata-section’. How do I apply the capture group in the overall query?
I am a complete beginner and I thank you in advance for your time.