I have some servers that are commonly having error 1000s. I want to find if it's the same application all the time, or if it's different applications. I am using this:
Get-EventLog application 1000 -entrytype error -newest 10 | select timegenerated,message | Export-Csv errors.csv
and the output shows the application name (specifically the exe file) as part of the multi-line message field.
I have not been able to figure out how to extract just the application name from the output.
Piping the output to Get-Member makes it look like the message field is an array, but I cannot figure out how to extract that part of the array at this point.
Get-EventLog application 1000 -entrytype error -newest 10 | %{$_.machinename,$_.timegenerated,$_.ReplacementStrings[0]}
This gives me the output I want, except it's generated over three lines, and Export-CSV doesn't want to parse it properly. How can I get them all on one line?
It's probably not going to be accurate for all event types, but the property
ReplacementStrings
is an array where the first element is the name of the executable when looking at InstanceID 1000:My PS-foo is weak at this time of the morning, but I'm sure there's a way to combine that with your
select
command and thus export them into your CSV.As per your update; this will get you the output you need in a table format. I don't know how well it will play with
export-csv
though:Never mind; I went way too complicated in my last update. This should work just fine (I knew I'd be better later in the day):