다음을 통해 공유


Write-EventLog

Writes an event to an event log.

구문

Default (기본값)

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

Description

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.

예제

Example 1: 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,20

This command writes an event from the MyApp source to the Application event log.

Example 2: 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."

This command writes an event from the MyApp source to the Application event log on the Server01 remote computer.

매개 변수

-Category

Specifies a task category for the event. Enter an integer that is associated with the strings in the category message file for the event log.

매개 변수 속성

형식:Int16
Default value:None
와일드카드 지원:False
DontShow:False

매개 변수 집합

(All)
Position:Named
필수:False
파이프라인의 값:False
속성 이름별 파이프라인의 값:False
나머지 인수의 값:False

-ComputerName

Specifies a remote computer. The default is the local computer.

Type the NetBIOS name, an IP address, or a fully qualified ___domain name of a remote 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.

매개 변수 속성

형식:String
Default value:None
와일드카드 지원:False
DontShow:False
별칭:CN

매개 변수 집합

(All)
Position:Named
필수:False
파이프라인의 값:False
속성 이름별 파이프라인의 값:False
나머지 인수의 값:False

-EntryType

Specifies 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.

매개 변수 속성

형식:EventLogEntryType
Default value:None
허용되는 값:Error, Information, FailureAudit, SuccessAudit, Warning
와일드카드 지원:False
DontShow:False
별칭:ET

매개 변수 집합

(All)
Position:3
필수:False
파이프라인의 값:False
속성 이름별 파이프라인의 값:False
나머지 인수의 값:False

-EventId

Specifies the event identifier. This parameter is required. The maximum value for the EventId parameter is 65535.

매개 변수 속성

형식:Int32
Default value:None
와일드카드 지원:False
DontShow:False
별칭:ID, EID

매개 변수 집합

(All)
Position:2
필수:True
파이프라인의 값:False
속성 이름별 파이프라인의 값:False
나머지 인수의 값:False

-LogName

Specifies 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.

매개 변수 속성

형식:String
Default value:None
와일드카드 지원:False
DontShow:False
별칭:LN

매개 변수 집합

(All)
Position:0
필수:True
파이프라인의 값:False
속성 이름별 파이프라인의 값:False
나머지 인수의 값:False

-Message

Specifies the event message. This parameter is required.

매개 변수 속성

형식:String
Default value:None
와일드카드 지원:False
DontShow:False
별칭:MSG

매개 변수 집합

(All)
Position:4
필수:True
파이프라인의 값:False
속성 이름별 파이프라인의 값:False
나머지 인수의 값:False

-RawData

Specifies the binary data that is associated with the event, in bytes.

매개 변수 속성

형식:

Byte[]

Default value:None
와일드카드 지원:False
DontShow:False
별칭:RD

매개 변수 집합

(All)
Position:Named
필수:False
파이프라인의 값:False
속성 이름별 파이프라인의 값:False
나머지 인수의 값:False

-Source

Specifies the event source, which is typically the name of the application that is writing the event to the log.

매개 변수 속성

형식:String
Default value:None
와일드카드 지원:False
DontShow:False
별칭:SRC

매개 변수 집합

(All)
Position:1
필수:True
파이프라인의 값:False
속성 이름별 파이프라인의 값:False
나머지 인수의 값:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

입력

None

You cannot pipe input to this cmdlet.

출력

EventLogEntry

This cmdlet returns objects that represents the events in the logs.

참고

For some Windows event logs, writing events requires administrator rights. You must start PowerShell using the Run as Administrator option.