8

Through PowerShell, I am attempting to create a new event log and write a test entry to it, but it is not showing up the Event Viewer. This is the command I'm using to create a new event log:

new-eventlog -logname TestLog -source TestLog

And to write a new event to it:

write-eventlog TestLog -source TestLog -eventid 12345 -message "Test message"

After running the first command, there is no "TestLog" log in the event viewer anywhere, and I would expect it to show up in the Applications and Services Logs section. After running the second command, same result. However, I am seeing a registry key for the log at HKLM\SYSTEM\services\eventlog\TestLog. Just not seeing anything in the event viewer.

So, 2 questions: When should I be seeing the event log? After it gets created or after I write the first event to it? And, more importantly, why am I not seeing it at all?

I'm using Windows Server 2008R2, and am logged in and running the PS as an administrator.

Thanks.

Matt
  • 291
  • 2
  • 9
  • 1
    Are you refreshing the `eventvwr.msc` after this? I copied/pasted your commands and it worked as expected. Right-click the "Applications and Services Logs" container and select "Refresh". – jscott Dec 13 '12 at 20:12
  • Yes, I have refreshed many times. There has to be something I'm missing... – Matt Dec 13 '12 at 20:15
  • 1
    @MegaMatt - are you running Powershell as an admin when creating the event source? I've had a lot of silent powershell failures without doing so. – Tim Brigham Dec 13 '12 at 20:22
  • Yes, running as an admin – Matt Dec 13 '12 at 20:26

1 Answers1

11

Terrible reason: I needed to close the Event Viewer and re-open. That's completely insane. Thanks for help.

Matt
  • 291
  • 2
  • 9
  • Odd, I guess your refresh was misbehaving. :) Glad you resolved this, please be sure [to accept your answer](http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work) when you are able. – jscott Dec 14 '12 at 00:45
  • I will second the "refresh" not being sufficient when creating a new log. Reload the viewer. – Jefferey Cave Jul 22 '15 at 14:42
  • Same issue. Had to restart computer for it to show! nothing else worked including restart Event Viewer. – user1675155 Jun 11 '20 at 21:24