CmdID

CmdID / PowerShell / Cmdlets / Write

Write-EventLog

Writes an event to an event log. PowerShell reference

From the PowerShell reference 8 parameters

Opens CmdID with your command, read as PowerShell. It is read in your browser and sent nowhere.

What it does

from the PowerShell reference, CC BY 4.0

Writes an event to an event log. The Write-EventLog cmdlet writes an event to an event log. To write an event to an event log, the event log must exist on the computer and the source must be registered for the event log. The cmdlets that contain the EventLog noun (the EventLog cmdlets) work only on classic event logs. To get events from logs that use the Windows Event Log technology in Windows Vista and later versions of the Windows operating system, use the Get-WinEvent cmdlet.

Write-EventLog [-LogName] <String> [-Source] <String> [[-EntryType] <EventLogEntryType>] [-Category <Int16>] [-EventId] <Int32> [-Message] <String> [-RawData <Byte[]>] [-ComputerName <String>] [<CommonParameters>]

Write an event to the Application event log

PS C:> Write-EventLog -LogName "Application" -Source "MyApp" -EventID 3001 -EntryType Information -Message "MyApp added a user-requested feature to the display." -Category 1 -RawData 10,20Identify

Write an event to the Application event log of a remote computer

PS C:> Write-EventLog -ComputerName "Server01" -LogName Application -Source "MyApp" -EventID 3001 -Message "MyApp added a user-requested feature to the display."Identify

Its page in the reference: Write-EventLog.

Parameters

8 in the PowerShell reference
-CategorySpecifies a task category for the event. Enter an integer that is associated with the strings in the category message file for the event log.
-ComputerNameSpecifies a remote computer. The default is the local computer. This parameter does not rely on Windows PowerShell remoting. You can use the ComputerName parameter of the Get-EventLog cmdlet even if your computer is not configured to run remote commands.
-EntryTypeSpecifies the entry type of the event. The acceptable values for this parameter are: Error, Warning, Information, SuccessAudit, and FailureAudit. The default value is Information. For a description of the values, see EventLogEntryType Enumeration.
-EventIdSpecifies the event identifier. This parameter is required. The maximum value for the EventId parameter is 65535.
-LogNameSpecifies the name of the log to which the event is written. Enter the log name. The log name is the value of the Log property, not the LogDisplayName. Wildcard characters are not permitted. This parameter is required.
-MessageSpecifies the event message. This parameter is required.
-RawDataSpecifies the binary data that is associated with the event, in bytes.
-SourceSpecifies the event source, which is typically the name of the application that is writing the event to the log.