$Servers = "<server01>", "<server02>"
$OutputDir = "<path>"
$now = Get-Date
$Message = @{ l= "Message";E={ (($_.Message -Split " `n") | foreach { $_ -split " "} | where {$_ -ne ""}) -join " " } }
$HistoryFrom = (Get-Date).AddDays(-20)
$Systemlog = Get-EventLog -ComputerName $Servers -LogName system -EntryType warning, error -After $HistoryFrom
$Applicationlog = Get-EventLog -ComputerName $Servers -LogName application -EntryType warning, error -After $HistoryFrom
$Systemlog + $Applicationlog | select MachineName, EventID, Source, EntryType, LastWriteTime, $Message |
Export-Csv "$OutputDir\Test.csv" -NoTypeInformation -Encoding ASCII -Delimiter ";"
|