SYNOPSIS

Creates a new event log in the Windows event log.

DESCRIPTION

The New-EventLog cmdlet creates a new event log for an application or service. You can use the event log to record events that occur during the operation of your application or service.

This cmdlet creates a new event log entry in the registry and registers the application or service with the Windows event log.

SYNTAX

New-EventLog -LogName <String> -Source <String> [-ComputerName <String[]>] [-MessageResourceFile <String>] [-CategoryResourceFile <String>] [-ParameterResourceFile <String>] [-ErrorAction <ActionPreference>] [-ErrorVariable <String>] [-OutBuffer <Buffer>] [-OutVariable <String>] [-PipelineVariable <String>] [-Verbose] [-Debug] [-InformationAction <ActionPreference>] [-InformationVariable <String>]

PARAMETERS

Name Type Description
-LogName String Specifies the name of the event log to create. This parameter is mandatory.
-Source String Specifies the name of the event source to register with the event log. The event source must be unique within the event log. This parameter is mandatory.
-ComputerName String[] Specifies the name of the computer on which to create the event log. The default value is the local computer.
-MessageResourceFile String Specifies the path to the message resource (.dll or .exe) file that contains the event messages.
-CategoryResourceFile String Specifies the path to the category resource (.dll or .exe) file that contains the event category strings.
-ParameterResourceFile String Specifies the path to the parameter resource (.dll or .exe) file that contains the event parameter strings.

EXAMPLES

Example 1: Create a new event log and source

New-EventLog -LogName "MyAppLog" -Source "MyAppSource"

This command creates a new event log named "MyAppLog" and registers "MyAppSource" as a valid source for that log on the local computer.

Example 2: Create a new event log with message resources

New-EventLog -LogName "MyServiceLog" -Source "MyService" -MessageResourceFile "C:\path\to\MyService.exe"

This command creates a new event log named "MyServiceLog" with the source "MyService" and specifies a custom message resource file.