So, I'm trying to write to the Windows event log using Write-EventLog . I collected the CategoryMessageFile.dll file and registered it in the registry.
My script writes to the event log for the most part, but the problem is that the event does not display the category name; it displays the category message id specified in the dll.
New-EventLog -LogName Application -Source 'test1' -CategoryResourceFile 'C: \ Windows \ Microsoft.NET \ Framework64 \ v2.0.50727 \ test.dll'
Write-EventLog -LogName Application -Source 'test1' -EntryType Information -EventId 1 -Message "$ ($ DataSet.Tables [0] .Rows [$ i] [6])" -Category 1
I know the display is correct, because when I run
Get-EventLog -LogName Application -Newest 3 | Format-list
The correct category name appears in the category for events that I just logged.
This is what my mc file looked like.
;// Header ;// Categories MessageIdTypedef=WORD MessageId=0x1 Language=English ETLUncategorizedError . MessageId=0x2 Language=English ETLThresholdExceeded . MessageId=0x3 Language=English ETLMalformattedFile . MessageId=0x4 Language=English ETLWebInvocationFailure .
So, how do I display the name instead of the number in the event log?
source share