Windows Event Log is a convenient event store to log information. Once data is in Windows Event log it can be correlated with other information on the system.
Where:
There two basic steps to do this:
- Create log location and source
- Write log information into that location and source
To create log location and source, do:
PS C:\> New-EventLog -LogName 8thstring -Source 8thSource
Where:
8thstring is the log location
8thSource is the source
You have to run this on an elevated PowerShell session. And if you have Windows Event Viewer open, you have to close it and re-open to see the new log. This should show up under Applications and Service Logs.
To write to that log location and source, do:
PS C:\> Write-EventLog -LogName 8thstring -Source 8thSource -Message "Hello world" -EventId 0 -EntryType information
-LogName 8thstring //8thstring was created using New-EventLog above
-Source 8thsource //8thSource was also created as part of New-EventLog call above
- Message "Hello world" //Message we wanted to write
-EventId 0 //User defined ID assigned for this message
-EntryType information // Can be (information|warning|error)
Reference(s):
Keywords:
PowerShell
Windows Eveng Log
Comments