I finally got the entire script working, thank you for your help.
Below are the 2 scripts, I apologize if they look a bit clunky, but they work:
Below is the script to pull all Event Logs for each server, filter them to only display Warnings, Failures, and FailureAudits for Application, System, and Security logs and then remove all duplicate EventIDs so only 1 of each is shown. it then exports that info into a .CSV per server.
param([string]$days= "31" )
$servers = @("Server1", "Server2" "Server3", "Etc")
$user = Get-Credential
#Set namespace and calculate the date to start from
$namespace = "root\CIMV2"
$BeginDate=[System.Management.ManagementDateTimeConverter]::ToDMTFDateTime((get-date).AddDays(-$days))
$store = "C:\Powershell\MonthlyMaintenance"
foreach ($computer in $servers)
{
$filter="TimeWritten >= '$BeginDate' AND (type='Warning' OR type='Error' OR type='FailureAudit')"
Echo "Pulling Event Logs for $computer ..."
Get-WmiObject Win32_NTLogEvent -computername $computer -Filter $filter |
sort eventcode -unique |
select Computername,
Logfile,
Type,
@{N='TimeWritten';E={$_.ConvertToDateTime($_.TimeWritten)}},
SourceName,
Message,
Category,
EventCode,
User |
Export-CSV C:\Powershell\MonthlyMaintenance\$computer-Filter.csv
}
Echo "Done."