BobSchleicher
MIS
There has to be a way to get this to export 1 csv instead of writing to result.csv then get result.csv and clean it then save as result_parsed.csv.
This gets the data I need:
After the above file is saved this process below cleans it up.
This gets the data I need:
Code:
$cl = $ComputerList = get-content c:\list.txt
$a = (Get-Date).adddays(-1)
Get-EventLog -ComputerName $cl -LogName system -After $a -Source print | select machinename,timegenerated,entrytype,message | Export-Csv c:\result.csv
After the above file is saved this process below cleans it up.
Code:
$original_file = 'c:\result.csv'
$destination_file = 'c:\result_parsed.csv'
(Get-Content $original_file) | Foreach-Object {
$_ -replace '"', '' `
-replace '#TYPE Selected.System.Diagnostics.EventLogEntry', '' `
-replace 'MachineName', '' `
-replace 'TimeGenerated', '' `
-replace 'EntryType', '' `
-replace 'Message', '' `
-replace ', ', ',' `
-replace ' owned by ', ',' `
-replace ' was printed on ', ',' `
-replace '. Size in bytes: ', ',' `
-replace '; pages printed: ', ',' `
} | Set-Content $destination_file