You can use the .NET EventLog class for this. It is quite simple to use, for example:
$eventSource = "MyAppName"
if (![Diagnostics.EventLog]::SourceExists($eventSource))
{
[Diagnostics.EventLog]::CreateEventSource($eventSource, "Application")
}
[Diagnostics.EventLog]::WriteEntry($eventSource, "message", [Diagnostics.EventLogEntryType]::Error)
source
share