How to export Windows eventlog to CVS file

Here you find a powershell script for export windows eventlog to a CSV file in readable format…

$DateAfter = [DateTime]::Today.AddDays(-1)
$ComputerName = "."
$MessageFind = "*usr7000*"
$DateLog = Get-Date -Format 'yyyyMMdd'
$CSVPath = "C:\Data\Working\eventlog$DateLog.csv"
Get-EventLog -logname "Security" -Computer $ComputerName -message $MessageFind -after $DateAfter  | Select Index,TimeGenerated,EntryType,Source,InstanceID,@{L='Message';E={($_.Message -replace '\s',' ')}} | export-csv -path $CSVPath
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s