# event-log-errors.ps1 — recent error count in System + Application logs. $Url = "YOUR_URL/event-errors" $Since = (Get-Date).AddHours(-1) $Filter = @{ LogName='System','Application'; Level=2; StartTime=$Since } $Events = Get-WinEvent -FilterHashtable $Filter -ErrorAction SilentlyContinue $Body = (@{ hostname = $env:COMPUTERNAME window_minutes = 60 total_errors = ($Events | Measure-Object).Count errors_by_provider = ($Events | Group-Object ProviderName | ForEach-Object { @{ ($_.Name) = $_.Count } } | ForEach-Object { $h = @{} } { foreach ($k in $_.Keys) { $h[$k] = $_[$k] } } { $h }) }) | ConvertTo-Json -Compress -Depth 4 Invoke-RestMethod -Uri $Url -Method Post -Body $Body ` -ContentType "application/json" -TimeoutSec 15 | Out-Null