I've been experimenting with .NET's Window's EventLog support. There's a class in System.Diagnositics called EventLog which lets you query the event log and add entries and so forth.
I had a C# program which created an event source on the Application Log like this:
if( !System.Diagnostics.EventLog.SourceExists("TestSource") )
System.Diagnostics.EventLog.CreateEventSource("TestSource",
"Application");
System.Diagnostics.EventLog.CreateEventSource("TestSource",
"Application");
and I needed to change it so that the event source was on a new custom log like this:
if ( !System.Diagnostics.EventLog.SourceExists("TestSource") )
System.Diagnostics.EventLog.CreateEventSource("TestSource",
"CustomLog");
System.Diagnostics.EventLog.CreateEventSource("TestSource",
"CustomLog");
To do this, I needed to delete the old event source, otherwise I would get an error because I was trying to use the event source with the wrong log.
I was about to write a tiny little C# program to say:
System.Diagnostics.EventLog.DeleteEventSource("TestSource");
And then I thought, "PowerShell!"
PS C:\> [System.Diagnostics.EventLog]::DeleteEventSource(
"TestSource")
"TestSource")
The create event source works better with :
ReplyDelete[system.diagnostics.eventlog]::CreateEventSource("CustomSource", "Customlog")
.. i guess!
-Vaibhav Singh.