New Eventlog - PowerShell
Overview
New-EventLog creates a new event log. Event logs are used to record events that occur on a computer. They can be used to troubleshoot problems, track security events, and monitor system performance.
Syntax
New-EventLog [-ComputerName <string>] -LogName <string> [-Source <string>] [-EventID <int>] [-ParameterString <string>] [-Message <string>] [-MaximumKilobytes <int>] [-MinimumKilobytes <int>] [-AutoBackup <switch>] [-SecurityDescriptor <string>]
Options/Flags
- -ComputerName: The name of the computer on which to create the new event log.
- -LogName: The name of the new event log.
- -Source: The source of the events that will be logged to the new event log.
- -EventID: The event ID of the first event that will be logged to the new event log.
- -ParameterString: A string that contains the parameters that will be passed to the event log.
- -Message: A message that will be logged to the new event log.
- -MaximumKilobytes: The maximum size of the new event log, in kilobytes.
- -MinimumKilobytes: The minimum size of the new event log, in kilobytes.
- -AutoBackup: A switch that specifies whether or not the new event log will be automatically backed up.
- -SecurityDescriptor: A string that contains the security descriptor for the new event log.
Examples
Example 1: Create a new event log named “MyEventLog” on the local computer.
New-EventLog -LogName "MyEventLog"
Example 2: Create a new event log named “MyEventLog” on the computer named “MyComputer”.
New-EventLog -ComputerName "MyComputer" -LogName "MyEventLog"
Example 3: Create a new event log named “MyEventLog” with a source of “MyApplication”.
New-EventLog -LogName "MyEventLog" -Source "MyApplication"
Common Issues
If you receive an error message when trying to create a new event log, it is likely because you do not have sufficient permissions. You must be a member of the Administrators group to create new event logs.
Integration
New-EventLog can be used with other PowerShell commands to perform a variety of tasks. For example, you can use New-EventLog to create a new event log and then use Write-EventLog to write events to the new event log.
Related Commands
- Get-EventLog: Gets an existing event log.
- Set-EventLog: Sets the properties of an existing event log.
- Clear-EventLog: Clears the events from an existing event log.