PowerShell 7.3 - Trouble Filtering Out Specific Event Logs While Exporting to CSV
Could someone explain I'm trying to filter out specific event logs from the Windows Event Viewer using PowerShell 7.3 and export the results to a CSV file... I want to exclude any logs that contain the source 'Application behavior' and 'Security'. However, when I apply the filter, I still see those entries in the CSV file. Hereβs the code snippet Iβm using: ```powershell $logs = Get-EventLog -LogName Application | Where-Object { $_.Source -ne 'Application behavior' -and $_.Source -ne 'Security' } $logs | Export-Csv -Path 'filteredLogs.csv' -NoTypeInformation ``` Despite this filtering logic, I noticed that some 'Application behavior' entries still appear in the output CSV. I also tried using `Get-WinEvent` to see if that might yield better results: ```powershell $logs = Get-WinEvent -LogName Application | Where-Object { $_.ProviderName -ne 'Application behavior' -and $_.ProviderName -ne 'Security' } $logs | Export-Csv -Path 'filteredLogs.csv' -NoTypeInformation ``` But the scenario continues. I have verified that the filters I applied in the `Where-Object` clause are correct. Additionally, I'm using the `-NoTypeInformation` parameter to avoid any type information being included in the CSV. Is there something I might be missing in my filtering? Are there any specific details about the event log filtering that I should be aware of? Any help would be greatly appreciated! The project is a CLI tool built with Powershell. Thanks for any help you can provide!