Tip: You can set the Event Log limit (MaximumSize) :
1 2 3 4 5 6 7 8 9 |
$logs = 'Application', 'System', 'Windows PowerShell' # Set event log size to 500 MB $logs | ForEach-Object -Process { Limit-EventLog -LogName $_ -MaximumSize 500MB } # Verify that the event log size is 500 MB $logs | ForEach-Object -Process { Get-WmiObject -Class Win32_NTEventlogfile -Filter "logfilename='$_'" } | Select-Object -Property LogfileName, MaxFileSize | Format-Table -AutoSize |