# User defined variables
$daysLimit=7
$startdate=(get-date).adddays(-$daysLimit)
$computername=$env:computername
$logName='Application'
$filterTypes='Error','Warning'
$logPath="c:\temp\eventlogs-from-$($startdate.tostring('yyyy-MM-dd'))-to-$((get-date).tostring('yyyy-MM-dd')).csv"

# Get the event logs
if(!(test-path $(split-path $logpath -parent))){$null=mkdir $(split-path $logpath -parent)}
$eventLogs = get-eventlog -ComputerName $computername -log $logName -After $startdate -EntryType $filterTypes
$eventLogs | export-csv $logPath