Files

20 lines
762 B
PowerShell
Raw Permalink Normal View History

2025-08-05 15:03:08 +00:00
<#
Author: Gabe Kerntke
Date: 05-15-2025
.Synopsis
Script to grab event viewer logs from the past 1 hour for System and Application (Warning and Errors only) and outputs to a CSV
.Modified
2025-05-15 (GabeK) - Original script created
#>
#Region Script Start
$Date = Get-Date -Format "MM-dd-yyyy"
$Begin = Get-Date
$End = $Begin.AddHours(-1)
Get-EventLog -LogName System -EntryType Error, Warning -After $End -Before $Begin | Export-Csv "C:\Temp\Script Cache\$Date-EventViewerLogs.csv"
Get-EventLog -LogName Application -EntryType Error, Warning -After $End -Before $Begin | Export-Csv "C:\Temp\Script Cache\$Date-EventViewerLogs.csv" -Append
Write-Host "Output saved to C:\Temp\Script Cache\$Date-EventViewerLogs.csv"
#Region Script End