I need to display a message to the user whenever the following Audit System event IDs occur: 1100, 1102, 1104, 1108, 4612, and 4719.
The title bar of the message window should say, as an example, "Event ID: 1100"
I also need to know how to trigger each of these events.
Here is what I've managed to accomplish so far: I am currently using Windows Task Scheduler. For Event ID 1102, I set up the following trigger:
On event - Log: Security, Source: Microsoft-Windows-Eventlog, EventID: 1102
Along with the following action to be run in powershell:
-executionpolicy bypass -windowstyle hidden -file C:\1102.ps1
And here is what my 1102.ps1 script looks like:
Add-Type -AssemblyName System.Windows.Forms
$lastEvt = Get-WinEvent -LogName 'Security' -MaxEvents 20 | ? { $_.Id -eq 1102 } | select -First 1
[System.Windows.Forms.MessageBox]::Show(($lastEvt.Message), 'Event ID: 1102')
By going into Event Viewer and clearing the Security log, I am able to make the desired message appear. However, I would like to be able to add a String argument to the end of my Task Scheduler action as opposed to typing out the string literal 'Event ID: 1102' in my .ps1 script. This will allow me to use the same script for any event ID.
On top of that, I have been unable to make the message appear for any other event (using the same trigger/action/script as detailed above but with the appropriate event IDs). For example, I made a system audit policy change (Event ID 4719) which was logged to the Security log in Event Viewer but for some reason did not display any message. As for the others, I have not yet figured out how to manually trigger them.