powershellScripts icon indicating copy to clipboard operation
powershellScripts copied to clipboard

event-log-manager.ps1 broken CSV output when XML has commas

Open maysara opened this issue 3 years ago • 1 comments

The csv output is broken when there are commas in the event XML.

maysara avatar Aug 23 '22 09:08 maysara

I propose to quote all csv fields.

This goes over them as an array, escapes double quotes, and padds them with doublequotes and seperates them with doublequotes and a comma

$outputEntry = '"{0}"' -f (($($event.TimeCreated.ToString("MM/dd/yyyy,hh:mm:ss.ffffff tt")),$($event.Id), $($event.LevelDisplayName),$($event.ProviderName),$($event.ProcessId),$($event.ThreadId), $($description) -replace '"','""') -join """,""")

maysara avatar Aug 23 '22 11:08 maysara

@maysara thanks for reporting. updated script..

jagilber avatar Apr 16 '23 12:04 jagilber