Skip to main content

Export Application and Security Logs to CSV

Summary

The script is designed to export Application and Security event logs into a CSV file with configurable options. The user can control which event levels (Critical, Warning, Error) to export, set the number of days to select events from, and specify the folder path for the exported CSV file.

The script checks the size of the generated CSV file. If the file size is less than 30MB, it proceeds to upload to the designated LTShare. If the CSV file is successfully uploaded, it is removed from the end machine to prevent clutter. If the file size exceeds 30MB, it remains on the end machine for review.

Sample Run

Sample Run

Variables

NameDescription
ProjectNameExport-Eventlogs
WorkingDirectoryC:/ProgramData/_Automation/script/Export-Eventlogs
ParamParameter set for the PowerShell script

User Parameters

NameExampleRequiredDescription
LevelCritical,Error,WarningFalseEvent type to export. Supported options are Critical, Error, and Warning. Multiple levels can be separated by a comma (without space or quotations). The default value is Critical.
Days180FalseNumber of days to select event logs from. Only integer values are supported. The default value is 30.
ExportPathC:/TempFalseFolder path for the exported CSV file. The default value is C:/Windows/Temp.

Quotations (both single and double) and spaces are not supported.

Output

  • Script Logs
  • File Upload