writing event log entries with powershell

just some more stuff i picked up hanging out with the #powershell guys.

 

# Writing an event
$EventLog = New-Object System.Diagnostics.EventLog('Application')
$EventLog.MachineName = "."
$EventLog.Source = "WorkstationEngineering"
$EventLog.WriteEntry("Testing Event","Warning", $EventID)

 

# viewing overloads
($myevent.WriteEntry).OverloadDefinitions

 

# Listing enums
[enum]::getvalues([system.diagnostics.eventlogentrytype])

Comments

  1. Beautiful. Short, clear and useful

    ReplyDelete
  2. Hi there...can you help me in this please...http://social.technet.microsoft.com/Forums/en-US/winserverpowershell/thread/f38114ef-e88f-4ebc-9fb2-043b6a8ca363

    Just trying to get the total count logged in the event viewer as well...please let me know....

    ReplyDelete

Post a Comment