Skip to content

Instantly share code, notes, and snippets.

@janikvonrotz
Created January 29, 2014 15:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save janikvonrotz/8690332 to your computer and use it in GitHub Desktop.
Save janikvonrotz/8690332 to your computer and use it in GitHub Desktop.
PowerShell: Moving an Event Source to a Different Windows Event Log #Markdown #WindowsServer #PowerShell

It is typically best practice when developing .NET applications, including SharePoint customizations, to create an event source for Windows Event Logging while installing the application. Each event source on a Windows computer is tied to a specific log upon registration. I recently provided guidance on how to move an event source to use its own brand new event log. The following lines of PowerShell can do this quickly. Unless your .NET application has the event log hardcoded into itself, which it shouldn’t because the event source should be registered to a log during installation, then the move shouldn’t require any code changes.

Remove-EventLog -Source MyCustomApplicationSource
New-EventLog -Source MyCustomApplicationSource -LogName MyNewOrExistingWindowsEventLog

I found that I had to reboot the machine after executing the above lines of PowerShell for this change to fully take effect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment