Exclude Particular Source from Get-Eventlog

Excluding particular source from Get-Eventlog is pretty easy, many of you would have found it. All you need to pipe the output and pass it to where clause to exclude particular sources.


One line PowerShell Command


Get-EventLog -ComputerName servername -LogName System -EntryType Error -Newest 100 | where {!(($_.Source -eq 'DCOM') -or ($_.Source -eq 'TermDD'))} | Select-Object EventID, MachineName, EntryType, Message, Source, TimeGenerated, TimeWritten, UserName | ConvertTo-Html | Out-String

The above script will exclude DCOM and TermDD source from the logs and displays EventID, MachineName, EntryType, Message, Source, TimeGenerated, TimeWritten, UserName