Friday, March 8, 2013

Windows Server 2008R2 - Manually Create an Event Log Event

So leading up to my next SCOM 2012 post How to Generate Alerts From the Event Log I first wanted to go over how to manually create events so you can test your monitoring later. Knowing how to set this up can be helpful for other things besides SCOM. You can use this in your scripting to note in the event log that a script ran, or completed. This trick can be used to write to just about any event log you wish.

The eventcreate command is what you will use to do this. You can pull up a list of switches in eventcreate by using the /? switch.  

Switch Action
/S Specifies the remote system you will be creating the event on
/U The username that will be used to execute the command
/P The password for the username. You will be asked for a password if you do not supply one
/L The event log you want to write to (i.e. System, Security, Application, etc.)
/T Specify the level of criticality of the error, Success, Error, Warning, Information
/SO You can specify the source of the event if needed
/ID You can specify the event ID for this event (between 1 and 1000)
/D This is the description of the event in quotes, "This is a test event"

The example I will be using in my next segment is:
eventcreate /l application /t information /id 1000 /so SCOMTest /d "This is a test event"

This will create an event with the ID of 1000 and a source of SCOMTest in the Application log.

More to come!

Like this blog, give it a g+1

No comments:

Post a Comment