I have a script that exports evens from the eventlog like:
Get-EventLog -LogName Application | Where-Object Source -Match "my application" | export-csv "$FileDate.csv"
When I open the CSV it does not look how I want it too. It shows
EventID,"MachineName","Data","Index","Category","CategoryNumber","EntryType","Message","Source","ReplacementStrings","InstanceId","TimeGenerated","TimeWritten","UserName","Site","Container" 0,"DESKTOP-ID94AN3","System.Byte[]","21425","(0)","0","Error","Finished executing project 'Testproject' Execution Package 'Failure' Execution failed Start Time : 21/12/2020 19:47:52 End Time : 21/12/2020 19:47:56 on server: DESKTOP-ID94AN3 -Logmessage
After text-to-columns:
With information in columns where it should not be. It seems to combine the 2 windows from the event viewer. The 'upper' window with the errors and the 'lower' window with the details. All I want is the upper window.
If I run this code in Windows Powershell ISE:
Get-EventLog -LogName Application | Where-Object Source -Match "Myapplication"
It looks how I want it too look (after using text to columns):
Index Time EntryType Source InstanceID Message
----- ---- --------- ------ ---------- -------
21425 Dec 21 19:47 Error Myapplication LogEn... 0 Message 1
21424 Dec 21 19:47 Information Myapplicationr LogEn... 0 Message 2
How do I get my CSV export to look like this also?
It looks how I want it too look:
and show what powershell shows after you import a CSV ... but that is not a CSV - it is a powershell array created by importing the CSV. ///// you CANNOT make a CSV that looks like that ... it would not be a CSV! [grin] it would only be a plain text file with almost zero structure. - Lee_Dailey