PowerShell command prompt

Use PowerShell to Create a New Event Log

Q: How can I create a new event log source in PowerShell?

A: If you want a new event log source available, you can use PowerShell to easily add one. For example, the following code adds a source named TestSource to the Application event log.

New-EventLog -LogName Application -Source TestSource

To actually write a log, you could use:

Write-EventLog -LogName Application -EventId 1234 -Source TestSource -Message "Test write"
Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish