Search Event Logs on Multiple Machines

Search Event Logs on Multiple Machines

$Computers = Import-Csv -Path C:\temp\servers.csv
$Log = "System"
$EventID = "4199"


$Results = foreach ($comp in $Computers){
Get-EventLog -LogName $Log -ComputerName $Comp.Name |Where-Object {$_.EventID -eq $EventID} |Select MachineName, Source, EventID, TimeGenerated
}

$Results | Export-Csv -Path logs.csv -NoTypeInformation

Leave a Reply

Your email address will not be published. Required fields are marked *