This issue seems to be related to how Get-WinEvent
processes the ForwardedEvents log, especially when filtering by time.
- Check the Event Log Service Status
Since the Windows Event Log service crashes, ensure it is running:
powershell
Get-Service -Name "EventLog"
If it is stopped, restart it:
powershell
Restart-Service -Name "EventLog" Force
Check Event Viewer(eventvwr.msc) under Windows Logs → System for errors related to EventLog or EventLog-ForwardingPlugin.
- Validate the Date Format in the Query
The problem could be due to $QueryDateTime not being properly expanded inside the XML query. Try using PowerShell string interpolation to ensure the value is properly inserted:
powershell
$QueryDateTime = (Get-Date).AddDays(-1).ToString("yyyy-MM-ddTHH:mm:ss.fffZ")
$Query = @"
<QueryList>
<Query Id='0' Path='ForwardedEvents'>
<Select Path='ForwardedEvents'>[System[TimeCreated[@SystemTime>='$($QueryDateTime)']]]</Select>
</Query
</QueryList
"@
Get-WinEvent -FilterXml $Query
If $QueryDateTime is not being expanded correctly, PowerShell may be passing an invalid XML structure, causing the crash.
3. Use a Different Time Format
Some versions of Windows Server may not support filtering *ForwardedEvents logs* with milliseconds (`.fZ`). Try using
powershell
$QueryDateTime = (Get-Date).AddDays(-1).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ")
Alternatively, without the "Z" (Zulu/UTC indicator):
powershell
$QueryDateTime = (Get-Date).AddDays(-1).ToString("yyyy-MM-ddTHH:mm:ss")
4. Check for Large Log Size Issues
The _ForwardedEvents_ log might be very large, and filtering directly on it could cause memory or RPC timeout issues. Try using a more specific filter, such as Event IDs:
powershell
$Query = @"
<QueryList>
<Query Id='0' Path='ForwardedEvents'>
sql
<Select Path='ForwardedEvents'>[System[(TimeCreated[@SystemTime>='$($QueryDateTime)']) and (EventID=4624)]]</Select>
</Query>
</QueryList>
"@
Get-WinEvent -FilterXml $Query
Replace 4624 with a common Event ID that exists in your log's
5. Use Get-WinEvent with FilterHashtable
Instead of FilterXml, try using FilterHashtable to check if the issue is XML related:
powershell
$StartTime = (Get-Date).AddDays(-1)
$FilterHashTable = @{
haskell
LogName = "ForwardedEvents"
StartTime = $StartTime
}
Get-WinEvent -FilterHashtable $FilterHashTable
If this works, then the problem is with how XML queries are being parsed.
6. Check Windows Event Forwarding (WEF) Subscription Settings
If the EventLog-ForwardingPlugin crashes, check:
powershell
wecutil es
If Windows Event Forwarding (WEF) is misconfigured, it could cause issues with ForwardedEvents. Verify:
Subscriptions are properly configured (wecutil gs to list subscriptions)
The ForwardedEvents log is not full or corrupted (eventvwr.msc → Applications and Services Logs → Microsoft → Windows → EventLog-ForwardingPlugin).
7. Check for Windows Server 2022 Bugs
Since this is a new server, check for pending updates and patches:
powershell
Get-WindowsUpdateLog
If issues persist, consider applying the latest Cumulative Update for Windows Server 2022.
In My Conclusion
1. Ensure theEvent Log service is running.
2. Use string interpolation for $QueryDateTime in XML.
3. Try different time. formats.(ToUniversalTime(), removing milliseconds).
4. Use FilterHashtable instead of XML as a workaround.
5. Limit query size by adding EventID filters.
6. Check WEF settings and Windows updates for potential fixes.