PowerShell 7.3 - Trouble Filtering Out Specific Event Log Entries by Source
I can't seem to get After trying multiple solutions online, I still can't figure this out. I'm reviewing some code and I've been struggling with this for a few days now and could really use some help. I tried several approaches but none seem to work. I'm trying to filter Windows Event Log entries based on their source using PowerShell 7.3, but I'm running into some unexpected behavior. When I use `Get-EventLog`, it seems to return all entries regardless of the source I'm trying to filter by. Here's what I've tried: ```powershell $sourceToFilter = "ApplicationError" $events = Get-EventLog -LogName Application | Where-Object { $_.Source -eq $sourceToFilter } ``` When I run this code, I still see entries from other sources, which is not what I expected. Instead of returning only entries from `ApplicationError`, it returns everything in the Application log. I've also attempted using `Get-WinEvent` with a filter hash table, but I face similar issues: ```powershell $filterHash = @{ LogName = 'Application'; ProviderName = 'ApplicationError' } $events = Get-WinEvent -FilterHashtable $filterHash ``` This returns an empty collection, even though I know there are entries from `ApplicationError` in the event log. I confirmed that the source name is correct and that it appears in the logs. I’ve checked the event log on the Event Viewer and can see `ApplicationError` listed among other sources. Is there a specific way I should be targeting the `ProviderName` in `Get-WinEvent`, or do I need to adjust my approach with `Get-EventLog`? Any insights on how to effectively filter event logs by source would be greatly appreciated. My development environment is Ubuntu. I'm working on a application that needs to handle this. Any help would be greatly appreciated! Could someone point me to the right documentation? This is for a mobile app running on Linux. What am I doing wrong?