Geeks With Blogs

News Please visit me at my new blog!!

profile for Aligned at Stack Overflow, Q&A for professional and enthusiast programmers
"free in Christ Jesus from the law of sin and death." Romans 8:2 (ESV) Check out the Falling Plates video on YouTube.
more about the Gospel
And then listen to Francis Chan speaking at LifeLight in SD.

Programming and Learning from SD

If you want to log to Windows Event Viewer you need to first create the EventLog and source. You can do this in C# or PowerShell. I’ve used LinqPad on the server before (run as administrator), but PowerShell can do the same thing. You could then run this as a script. I haven’t used PowerShell a lot, but it was a good experience using it.


Create the Event Log with source

new-eventlog -logname MyLogMaybeYourCompanyName -source MyApplicationName

Write to the Event Log to test

write-eventlog -logname MyLogMaybeYourCompanyName -source MyApplicationName-entrytype Information -message "TestMessage from PowerShell" -eventid 3001

Get the entries in the Event Log

you don’t have to open Event Viewer.

get-eventLog -LogName MyLogMaybeYourCompanyName -source MyApplicationName

Remove the Source from the Event Log

remove-eventlog -source MyApplicationName



Posted on Wednesday, March 4, 2015 11:08 AM | Back to top

Comments on this post: EventLogs with PowerShell

# re: EventLogs with PowerShell
Requesting Gravatar...
Left by faruk on Mar 08, 2015 1:15 AM

Your comment:
 (will show your gravatar)

Copyright © Aligned | Powered by: