PowerTip: Use PowerShell to Write to an Event Log

Summary: Use the Write-Eventlog Windows PowerShell cmdlet to write to a standard or to a custom event log.

 Hey, Scripting Guy! Question How can you easily write output to an event log?

Hey, Scripting Guy! AnswerUse the Write-EventLog cmdlet, and make sure that you specify the log name and the source:

write-eventlog -logname Application -source MyApp -eventID 3001 -entrytype Information `

-message “MyApp added a user-requested feature to thedisplay.” -category 1 -rawdata 10,20